Re: [elm-discuss] Encoding JSON and updating

2017-11-19 Thread David Andrews
This depends on the backend server you are using and its configuration.  It
has nothing to do with Elm.

I recommend against running your server as Administrator as a security
practice.


On Nov 19, 2017 2:05 AM, "David Legard"  wrote:

I am using a simple JSON decode and encode (following from examples at
elm-tutorial ), but I'm clearly missing
something.

The *db.json* file has the simple structure

{
 "plrs": {
 "ixd": "FF",
 "name": "Frank",
 "level": 3
 }
}


.. and I decode that successfully into an Elm object with an HTTP Get:
from *http://localhost:3000/db
. *The Elm object holding the data has the type*
Roster.*

When I encode it, and try to save it with an HTTP Send (to the identical
URL), I get a *File Not Found 404* error.

Do I need to tweak the URL for sending the data back, or would a mistake in
my Encoding code (quite a possibility) cause this to happen?

I'm running this as Administrator in case there are any permission issues.

I am using the code in the tutorial to create the HTTP request, as follows:

savePlayerRequest : Roster -> Http.Request Roster
savePlayerRequest roster =
Http.request
{ body = plrsEncoder roster |> Http.jsonBody
, expect = Http.expectJson plrsDecoder
, headers = []
, method = "PATCH"
, timeout = Nothing
, url = savePlayerUrl
, withCredentials = False
}

-- 
You received this message because you are subscribed to the Google Groups
"Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Arbitrary length currying

2017-11-06 Thread David Andrews
Sorry I misread your example as a single list argument.

Strictly speaking, you can not call a function with no arguments in Elm,
but some functions take Unit as an argument.

There are a couple of roadblocks preventing this exact functionality in
Elm.  Firstly, Elm does not allow recursive types
<https://ellie-app.com/5YDsxhFLSa1/0>.  Secondly, a name in Elm must have
the same type everywhere it is mentioned.  Even normal function overloading
is not possible <https://ellie-app.com/5YDsxhFLSa1/1> without renaming the
function.

The closest I could come up with was this
<https://ellie-app.com/g4DpfMDxPa1/1>, which I don't think will be very
satisfactory to you, but I believe is isomorphic to the Haskell example.
You just have to explicitly name all of the function applications in Elm.


On Nov 6, 2017 11:53 AM, "Ray Toal"  wrote:

Thanks but I was looking not for the obvious, practical approach for
summing integers but was interested in the puzzle of arbitrary-length
currying. When called with no arguments, the function should yield its sum
so far. When called with a single argument, the function should return a
function that knows about what it has seen so far. It sounds stateful, but
can be done without state. But since Elm is statically typed and doesn't
have overloading, I'm wondering if this can even be done with currying.


On Monday, November 6, 2017 at 4:23:21 AM UTC-8, David Andrews wrote:

> The solution for the list version is very straightforward in elm:
> https://ellie-app.com/g4DpfMDxPa1/0
>
> On Sun, Nov 5, 2017 at 10:39 PM, Ray Toal  wrote:
>
>> There's an interesting problem on the Programming Puzzles and Stack
>> Exchange on arbitrary length currying here: https://codegolf.stackex
>> change.com/questions/117017/arbitrary-length-currying. It asks for a
>> function f behaving as follows:
>>
>> f () = 0
>> f (3)(9)(2)() = 14
>>
>> This is trivial in dynamically typed languages that don't care about the
>> number of arguments, and is easy to do in statically typed languages which
>> allow overloading. But what about the ML-like languages?
>>
>> The only ML-like language with a solution is Haskell. Its author says 
>> "Forcing
>> Haskell's strict type system to allow this requires some magic, namely,
>> enabling the GHC extension for flexible typeclass instances."
>>
>> Is this problem impossible in Elm?
>>
>> If impossibie, can a solution be found to a related problem, say where
>> the arguments are lists?, e.g.
>>
>> f [] = 0
>> f [3] [9] [2] [] = 14
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss...@googlegroups.com.
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
You received this message because you are subscribed to the Google Groups
"Elm Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Arbitrary length currying

2017-11-06 Thread David Andrews
The solution for the list version is very straightforward in elm:
https://ellie-app.com/g4DpfMDxPa1/0

On Sun, Nov 5, 2017 at 10:39 PM, Ray Toal  wrote:

> There's an interesting problem on the Programming Puzzles and Stack
> Exchange on arbitrary length currying here: https://codegolf.
> stackexchange.com/questions/117017/arbitrary-length-currying. It asks for
> a function f behaving as follows:
>
> f () = 0
> f (3)(9)(2)() = 14
>
> This is trivial in dynamically typed languages that don't care about the
> number of arguments, and is easy to do in statically typed languages which
> allow overloading. But what about the ML-like languages?
>
> The only ML-like language with a solution is Haskell. Its author says "Forcing
> Haskell's strict type system to allow this requires some magic, namely,
> enabling the GHC extension for flexible typeclass instances."
>
> Is this problem impossible in Elm?
>
> If impossibie, can a solution be found to a related problem, say where the
> arguments are lists?, e.g.
>
> f [] = 0
> f [3] [9] [2] [] = 14
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Using equally named modules from different packages

2017-09-23 Thread David Andrews
https://github.com/elm-lang/elm-compiler/issues/1625

On Sat, Sep 23, 2017 at 7:24 AM Pi  wrote:

> Hi!
>
> Does someone know how to import modules with the same name from different
> packages?
>
> Eg. mdgriffith/style-elements exposes module "Element", as does
> evancz/elm-graphics.
>
> It seems I can't use both packages in the same project, since when I
> import Element, compiler complains that "there are multiple modules named
> 'Element'".
>
> Hoping for help,
> Matthias
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Systemic problem in Object Oriented languages

2017-07-24 Thread David Andrews
As far as I'm concerned, this is just syntactic sugar.  I've noticed that
elm has a convention to use the last parameter in a function where an OO
programmer would use this.  Using this convention, code winds up being very
similar when used.

OO version:
model
.getSomeProperty
.withDefault(3)

Elm version:
model
|> getSomeProperty
|> Maybe.withDefault 3



On Mon, Jul 24, 2017 at 1:50 PM Dave Ford  wrote:

> A lot of my early work was centered around UIs which made heavy use of
>> inheritance and mutation.
>>
> I really don't think this is related to the original question. The
> original question was not about inheritance or mutation or even about OO.
> It was about "this" and "combining data with logic". Which were described
> as a "systemic problem".
>
> No one (yet) has convinced me that they are even remotely a problem. No
> one has provided an example. Or any logic to support the claim.
>
> They have mentioned all sorts of other things that *are* problematic,
> like inheritance and mutation. But I already knew those were problematic. I
> also already knew that most OO languages also support mutation (although
> mutation is discouraged in Kotlin). But this is not what the question was.
>
> Sure, you could start naming off a dozen other things that are problematic
> (like inheritance and mutation). But that has nothing to do with the
> question.
>
>
>> In OO, mutation is very easy to do because of `this`.
>>
> No. As mentioned earlier, "this" has nothing to do with immutability.
> "this" is just an object variable like any other object variable.
>
> | Perhaps your experience with OO programming is atypical?
> The fact that "this" has nothing to do with immutability is unrelated to
> my experience.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-19 Thread David Andrews
Regarding the toString solution, there is a package which does this:
http://package.elm-lang.org/packages/ccapndave/elm-reflect/1.0.0/Reflect

Another downside I can think of is that it can only tell you if two values
have constructors with the same name.  If the same name is used in multiple
files, they will appear to be equal.

On Tue, Jul 18, 2017 at 2:25 PM Birowsky  wrote:

> I agree. Here it goes:
>
>
> type Route
>   = Route1 SubRoute1
>   | Route2 SubRoute2
>
>
> Routes are coming into the app. I want to detect when the base route
> changes. Example, from Route1_, to Route2 _.
>
> (This is part of solution to a challenge where I need to keep the scroll
> position of a list view upon a navigation to one of it's list items, so
> that when the user goes back, he's faced with the same scroll position. The
> approach that I'm taking is by not destroying the list view in the first
> place. Problem there is that there might happen a buildup of multiple list
> views causing memory pressure, so we still need to decide when is a good
> time to destroy the list view. The way I rationalize: if after the list
> item navigation, the user makes another base navigation, he doesn't care
> about the scroll position of the list view. Ergo,  I want to detect when
> the base route changes. You can check out this behavior in the list views
> in Dscova . I took a different
> approach where I'm tracking the routes history.)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-17 Thread David Andrews
Similar code, with new cases enforced by the compiler

haveSameConstructor : Bla -> Bla -> Bool
haveSameConstructor first second =
case (first, second) of
(A _, A _) -> True
(B _, B _) -> True
(A _, _) -> False
(B _, _) -> False

On Jul 17, 2017 3:34 AM, "Birowsky"  wrote:

> That's not so bad. But the compiler wouldn't be able to nudge me to add a
> new comparison when I add a new constructor in the Bla union.
>
> Thanx anyways.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] ADT: How to know whether two values have the same constructor?

2017-07-16 Thread David Andrews
You could write something like:

haveSameConstructor : Bla -> Bla -> Bool
haveSameConstructor first second =
case (first, second) of
(A _, A _) -> True
(B _, B _) -> True
_ -> False

On Sun, Jul 16, 2017 at 6:33 PM Birowsky  wrote:

> Given:
>
> type Bla = A Int | B Int
> valA1 = A 1
> valA2 = A 2
>
>
> Is there a way for me to check whether `valA1` has been constructed with
> the constructor of `valA2`?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Unexpected compiler behaviour and message "pattern is redundant".

2017-07-09 Thread David Andrews
`case` statements in elm can not match variables.  Both of these branches
look to the compiler as if they match everything.  It interprets
`messageParam` as the name of a variable to which to bind the match, which
in this case will be `node.message`.

On Sun, Jul 9, 2017 at 5:04 PM jadski  wrote:

> With manual formatting
>
> *Code*
>
> type Message = Good | Bad | ManyOthers
>
> type alias Node = { message : Message }
>
> trymatch : Node -> Message -> Bool
> trymatch node messageParam =
> case node.message of
> messageParam ->
> True
> _ ->
> False
>
> evalTrue = trymatch { message = Good } Good
> evalFalse = trymatch { message = Good } Bad
>
>
> *Error Message*
>
> The following pattern is redundant. Remove it.
>
> 10| _ ->
> ^
> Any value with this shape will be handled by a previous pattern.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Making useless HTML Attributes impossible

2017-07-01 Thread David Andrews
We could define a type for the attributes of each html element and pass
that as the list of attributes when defining the Html.

Html/Attributes.elm
type A msg = Href String | OnClick msg | ...

Html.elm
a : (List Html.Attributes.A msg) -> (List Html msg) -> Html msg

main.elm
Html.a [Html.Attributes.Href "#"] []

This would cause some naming woes for us, though, since both image and
iframe couldn't both have attributes named Src in the same package.  We
would either have to move them to separate packages or name them ImgSrc and
IframeSrc or the like.

On Sun, Jul 2, 2017 at 12:33 AM Peter Damoc  wrote:

> On Sat, Jul 1, 2017 at 9:35 PM,  wrote:
>
>> It's been some time that I'm thinking about type checking HTML Attributes
>> to ensure at compile time that useless attributes can't be set on HTML. For
>> instance, it makes no sense to set Html.Attributes.src to an h1 title.
>>
>
> To my understanding this restriction would have to be expressed in the
> type signature.
> How would the type signature for the `h1` would look like exactly?
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Feature: 'where' expressions (continued from GitHub)

2017-01-03 Thread David Andrews
You could also imagine a parsing of where, where the following would be the 
way to write this:
f tree =
  case tree of
Leaf x ->
  munge a b
  where
b = ...
Node s t ->
  munge a c
  where
c = ...
  where
a = ...

 



On Tuesday, January 3, 2017 at 1:26:33 AM UTC-5, Janis Voigtländer wrote:
>
> And do you like that version? It seems to not have the advantages usually 
> claimed for "where" in this discussion. For example, you define "a" before 
> using it. What about "intent first" here? And in some sense, this 
> formulation now looks like a dual to the workaround Joey proposed with 
> "let" to please "where" proponents. Isn't it strange that "a" and "work" 
> look like they might be mutually recursive now, when they are actually not 
> and when the "let"-formulation made that explicitly visible?
>
> Am 02.01.2017 um 23:10 schrieb Colin Woodbury  >:
>
> @Janis, I suppose the `where` version of that formation would have to be:
>
> f tree = work
>   where a = ...
> work = case tree of
>   Leaf x -> -- using a and b 
>  
> where b = ...
>   Node s t -> -- using a c   
>  
> where c = ...
>
>
> On Sunday, 1 January 2017 12:21:47 UTC-8, Janis Voigtländer wrote:
>>
>> Janis, the following compiles for me: …
>>
>> Right, where does not work for expressions, but for right-hand sides, of 
>> which pattern match branches are an instance.
>>
>> The next question would be, still under the assumption that a choice has 
>> to be made between where and let because both won’t be made available at 
>> the same time, how well “where-only” would work if in addition one wants 
>> to have a local binding that spans all pattern match branches, i.e., 
>> something one would currently write in Elm like so:
>>
>> f tree =
>>   let
>> a = ... something ...
>>   in
>> case tree of
>>   Leaf x -> let b = ... in ... using a and b ...
>>   Node s t -> let c = ... in ... using a and c ...
>>
>> ​
>>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elm-discuss...@googlegroups.com .
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Feature: 'where' expressions (continued from GitHub)

2017-01-01 Thread David Andrews
Is there something fundamental about `where` clauses which would prevent
them from parsing as expressions, or is this an artifact of how they are
implemented in Haskell?

On Sun, Jan 1, 2017 at 9:21 PM Janis Voigtländer <
janis.voigtlaen...@gmail.com> wrote:

>
>
> Janis, the following compiles for me: …
>
>
>
> Right, where does not work for expressions, but for right-hand sides, of
> which pattern match branches are an instance.
>
>
> The next question would be, still under the assumption that a choice has
> to be made between where and let because both won’t be made available at
> the same time, how well “where-only” would work if in addition one wants
> to have a local binding that spans all pattern match branches, i.e.,
> something one would currently write in Elm like so:
>
>
> f tree =
>
>   let
>
> a = ... something ...
>
>   in
>
> case tree of
>
>   Leaf x -> let b = ... in ... using a and b ...
>
>   Node s t -> let c = ... in ... using a and c ...
>
>
>
> ​
>
>
>
>
>
>
>
>
> --
>
>
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
>
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
>
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Feature: 'where' expressions (continued from GitHub)

2016-12-30 Thread David Andrews
For those not following the bug, the question is: What real-world problems
do you have (if any) that would be solved by a Haskell-like `where` syntax,
which are not already solved by the current `let...in` syntax?

On Fri, Dec 30, 2016 at 6:10 PM Will White  wrote:

> Continued from https://github.com/elm-lang/elm-compiler/issues/621.
>
>
>
>
>
>
>
>
> --
>
>
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
>
>
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
>
>
> For more options, visit https://groups.google.com/d/optout.
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Why not components?

2016-12-06 Thread David Andrews
They have equality but not comparison.  They can't be used as a Dict key,
for instance.

On Dec 5, 2016 5:39 PM, "Peter Damoc"  wrote:

> This is weird.
> For some reason I got it into my head that tags are not comparable.
> Now I can't remember when or why.
>
> The code seams to work on my end too and for my sanity I checked it on
> 0.17 and 0.16 and it works in those versions too.
> weird.
>
>
>
>
> On Mon, Dec 5, 2016 at 11:59 PM, Wouter In t Velt <
> wouter.intv...@gmail.com> wrote:
>
>> Op maandag 5 december 2016 22:51:02 UTC+1 schreef Peter Damoc:
>>>
>>> You cannot use comparison on tags.
>>>
>>
>> I can see your version is cleaner.
>> Do you mean a comparison with a maybe is not allowed? Like this?
>> -- is this not allowed?
>> if someMaybe == Just 42 then
>>  ...
>>
>> The original change I made did seem to work at my end, and the compiler
>> didn't complain..
>> Or is it convention rather than rule?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Elm Discuss" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to elm-discuss+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: One month with Elm, two questions

2016-12-05 Thread David Andrews
A syntax that would make sense with current trends in elm is something to 
the effect of:

model
  |> Record.map .val1 increase
  |> Record.update .val2 42


This of course relies on `Record.map` and `Record.set` which do not exist 
and (ab)uses .field syntax in ways which don't actually work.


On Monday, December 5, 2016 at 4:02:49 PM UTC-5, Wouter In t Velt wrote:
>
> Op maandag 5 december 2016 21:00:35 UTC+1 schreef Frankie Sardo:
>>
>> Why does the update syntax accept just a new value instead of accepting a 
>> function that updates (or creates) the new value?
>>
>
> Don't know about Clojure, but Elm likes you to be explicit and consistent 
> about functions, meaning: if the function requires an argument, then you 
> should provide an argument if you want to use the output of the function 
> instead of the function itself.
>
> So, you could use the functions you describe, as long as you also pass the 
> argument:
>
>   { model 
>   | val1 = increase model.val1
>   , val2 = always42 model.val2
>   }
>
> You can find a working example here 
> Hope this helps
>
>
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Re: Pattern matching using existing bound variables

2016-12-05 Thread David Andrews
That is what I meant.  I will often use this pattern as follows:

orSomething : Maybe String -> String
orSomething str =
  case str of
Just str -> str
Nothing -> "something"

I realize, though, that I misunderstood the original question.  

On Monday, December 5, 2016 at 3:25:07 PM UTC-5, Duane Johnson wrote:
>
>
> On Sun, Dec 4, 2016 at 6:53 PM, David Andrews  > wrote:
>
>> I expect that you are actually looking to do something like this:
>>   let
>> x = 1
>>   in
>> case something of
>>   Just x -> ...
>>   Nothing -> ...
>>
>
> David, are you sure you didn't mean the following?
>
> case something of
>
>Just 1 -> ... 
>
>Nothing -> ...
>
>
> It seems strange to include a shadowed variable `x` as in your expected 
> code.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Why not components?

2016-12-05 Thread David Andrews
A tiny note: To avoid the confusing inclusion of `Position` in `Blur`, you
can remove the `Position` and pass `always Blur` to `Mouse.clicks`.

On Sun, Dec 4, 2016 at 10:51 AM, Wouter In t Velt 
wrote:

> Op zondag 4 december 2016 15:43:40 UTC+1 schreef Peter Damoc:
>>
>> You're trading one set of boilerplate for another.
>>
>
> Fair enough. I could have pointed that out in the conclusions.
>
> Both your versions are almost as bad as you are forcing internal details
>> of the functioning of the dropdown onto the user of the dropdown.
>>
>
> Could you explain this? I am not sure I follow what you are saying here.
> Wouldn't we always enforce some kind of API from the dropdown on the user?
> Or what would need to be different in both versions to not "force
> internals .. onto the user" ?
>
> The pure version is indeed more aligned with the current recommendations
>> but it is almost as bad from a library user point of view.
>>
>
> Taking the pattern and consequences from a dropdown to a library is
> something that I did not consider. Maybe I should have.
>
>
>> In order to have a full treatment of the issue, implement a
>> webcomponents/polymer version of the same functionality and then argue that
>> the "pure" version is better.
>>
>
> By no means did I intend to make a full treatment of the issue, or claim
> that pure is always better than stateful.
> Admittedly, the wording of the last paragraphs was too strong, so I
> changed that.
>
> I follow the uptake of integrating web components/ polymer with much
> interest.
> The argument in the article was made specifically where the dev is
> building everything in elm, and wants to structure his/her code when the
> app grows.
> The implementation of a Polymer version is a different scenario IMHO.
> But thank you for the challenge, I'll look into it ;)
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Elm Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Pattern matching using existing bound variables

2016-12-04 Thread David Andrews
I think the problem is slightly different than you think.  The reason the 
compiler complains about the redundant pattern is that "x" already matches 
everything.  There are no more cases for "_" to handle.

This compiles with no problem:
  let
x = 1
  in
case something of
  x -> ...


I expect that you are actually looking to do something like this:
  let
x = 1
  in
case something of
  Just x -> ...
  Nothing -> ...

On Sunday, December 4, 2016 at 6:05:10 AM UTC-5, Michał Podwórny wrote:
>
> Thanks for clearing things out!
>
> W dniu niedziela, 4 grudnia 2016 02:40:41 UTC+1 użytkownik Michał Podwórny 
> napisał:
>>
>> Hi,
>>
>> Consider this:
>> let
>>   x = 1
>> in
>>   case something of
>> x -> (...)
>> _ -> (...)
>>
>> The compiler will complain that "The following pattern is redundant", 
>> pointing to the wildcard. I assume that Elm ignores the fact that "x" is 
>> already bound, re-binds it in the first case match and that indeed makes 
>> the wildcard redundant. I know how I would do this in Elixir: I'd put "^" 
>> before "x" to explicitly say not to re-bind the x variable. Is there 
>> something like this in Elm?
>>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Rename Just to Something, as the counterpart to Nothing?

2016-11-22 Thread David Andrews
I don't think it really works for this, but the natural definition for
Maybe would seem to be

Maybe a = Yes a | No

On Nov 22, 2016 11:30 AM, "Will White"  wrote:

> I see.
>
> We’re happy using the ungrammatical Ok a for Results, so why not Thing a
> for Maybes?
>
> On 22 Nov 2016, at 13:06, 'Andrew Radford' via Elm Discuss <
> elm-discuss@googlegroups.com> wrote:
>
> I think his point was if it was a Maybe List Int, then you would have
>
> 'A items'
>
> It still seems English is not up to this task :) We should probably just
> make up a new word, start using it day to day, then have it included in the
> OED. If it can be done for 'selfie
> ', then we could do
> it for 
>
> On Tuesday, 22 November 2016 10:35:48 UTC, Will White wrote:
>>
>> type Maybe thing = A thing | Nothing
>>
>> So with List.head list I’d get A 2 or Nothing.
>>
>> On 22 Nov 2016, at 10:20, Oliver Searle-Barnes  wrote:
>>
>> The problem with Some is that it should be A/An/Some depending on the
>> subject. I'm starting to come round to Thing vs Nothing. While the grammer
>> isn't spot on the semantics are very clear.
>>
>>
>> On Tuesday, 22 November 2016 11:06:10 UTC+1, Will White wrote:
>>>
>>> weapon = Just sword doesn’t make sense for Maybe. It implies “just
>>> sword, out of all the weapons”. Just *would*make sense in a Just weapon
>>> | All (List weapon) type, where weapon could also be All [ sword, mace,
>>> nunchuk ].
>>>
>>> I think we all agree that Nothing totally nails its concept (better than
>>> null for the uninitiated). I'm just looking for a word that implies its
>>> alternative is Nothing, e.g. Thing, Something. If it’s grammatically
>>> correct, that’s a bonus, but I think eliminating things which hinder
>>> understanding is more important.
>>>
>>> On 22 Nov 2016, at 00:24, joseph ni  wrote:
>>>
>>> I came to Elm not knowing about the Maybe type.
>>> The hardest thing for me to grasp was the use case and being able to map
>>> : (a -> b) -> Maybe a -> Maybe b. And knowing when to use a Maybe (rarely)
>>> vs when to use a union type or refactor the code so it doesn't need the
>>> Maybe type.
>>>
>>> If I was to qualitatively estimate the amount of time spent learning
>>> about Maybe. I'd say it took me a moment to understand `Maybe a = Just a |
>>> Nothing` and a couple of months to get comfortable enough with the Maybe
>>> type now to understand where it's needed in my app.
>>>
>>> So I'd tend to lean with Joey, the wording works for me and changing it
>>> would feel arbitrary and break the current grammatical 'symmetry' as in
>>> weapon = Just sword
>>> vs
>>> weapon = Something sword
>>>
>>> On Tuesday, 22 November 2016 08:19:21 UTC+11, Oliver Searle-Barnes wrote:

 I have to admit I did find `Just` very confusing when I first
 encountered it, as mentioned earlier in this thread it implies some kind of
 limitation which doesn't match the semantics of Maybe at all. That said, it
 was one of those little oddities that very quickly become second nature,
 just wanted to point out that it is a slight bump in the road for 
 newcomers.


 On Monday, 21 November 2016 18:34:05 UTC+1, Noah Hall wrote:
>
> Has anyone actually encountered anyone being confused by the names? I
> haven't. I think this a solution to a problem that doesn't exist.
>
> On Mon, Nov 21, 2016 at 6:15 PM, Will White 
> wrote:
> > I think that’s because you already know what Just means. I don’t
> think it’s
> > arbitrary though from an accessibility point of view. Some or None
> is easier
> > for newcomers to understand than Just or Nothing, especially as Some
> isn’t
> > misleading the way Just is, as Andrew described well.
> >
> > On 21 Nov 2016, at 17:05, Joey Eremondi  wrote:
>
> >
> > Honestly, these choices seem pretty arbitrary. Everyone has a
> preference. ML
> > uses Some/None, Haskell uses Just/Nothing. Some people find Something
>
> > intuitive, some don't.
> >
> > Given that the choices is (mostly) arbitrary, it seems best to stick
> with
> > the status quo.
> >
> > On Mon, Nov 21, 2016 at 7:47 AM, 'Andrew Radford' via Elm Discuss
> >  wrote:
> >>
> >> Probably inherited from Haskell, like a lot of other stuff. Doubt
> if there
> >> was any other thought put into it if I'm honest.
> >>
> >> On Monday, 21 November 2016 14:46:40 UTC, Will White wrote:
> >>>
> >>> Sorry, meant to say “I guess he’s already considered and rejected
> them”.
> >>>
> >>> On 21 Nov 2016, at 14:21, Will White  wrote:
> >>>
> >>> I prefer Some or None, for understanding. Though, unless Evan
> didn’t know
> >>> about them, I guess we’d already have them.
> >>>
> >>> On 20 Nov 2016, at 23:41, Robin Heggelund Hansen <
> skinn...@gmail.com>
> >>> wrote:
> >>>
> >>> How about 'Some' and 'No

Re: [elm-discuss] 0.17-compatible web storage

2016-10-31 Thread David Andrews
Because primitives rock.  If we expose API primitives in a typesafe way, we
allow the community to use them to create useful libraries.

I actually see that the persistent cache package has a LocalStorage module
which exposes a subset of my proposed API.  However, It does not implement
the storage event which allows for easy synching across open tabs/windows.
It also does not implement any bindings for sessionStorage.

On Oct 31, 2016 8:40 AM, "Joe Clay" <27cupsofcof...@gmail.com> wrote:

> I think it ties in with the general theme of Elm trying to guide you into
> making the right choices - if there's no real use case for LocalStorage
> other than using it as a cache, why expose the low level bindings and allow
> people to shoot themselves in the foot with them?
>
> On Monday, October 31, 2016 at 7:22:44 AM UTC, David Andrews wrote:
>>
>> Thanks for pointing me to that, and the Justification section therein
>> answers my next question.  However, I don't see why it makes sense to
>> conflate the use of the web storage API with a cache pattern.  It seems to
>> me that the best way to do this would be to make the low-level API
>> available and implement a cache on top of that.
>>
>> On Monday, October 31, 2016 at 2:55:42 AM UTC-4, Peter Damoc wrote:
>>>
>>> On Mon, Oct 31, 2016 at 8:38 AM, David Andrews 
>>> wrote:
>>>
>>>> I would really like to be able to use local storage in elm.  There have
>>>> been several libraries that implement this, but none of them have been
>>>> updated to elm 0.17.  So far the advice I've seen is just to wait, but I'm
>>>> tired of waiting.
>>>>
>>>
>>> It's not really storage when you have a hard limit of 5MB of data.
>>> persistent-cache <https://github.com/elm-lang/persistent-cache> will
>>> probably end up covering the uses for that kind of functionality.
>>>
>>> You should be using ports but if you really really want to use the
>>> unreleased library, fork it, tag it with 1.0.0 and install it with
>>> elm-github-install.
>>>
>>>
>>> --
>>> There is NO FATE, we are the creators.
>>> blog: http://damoc.ro/
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/idgmRP24Aj0/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] 0.17-compatible web storage

2016-10-31 Thread David Andrews
Thanks for pointing me to that, and the Justification section therein 
answers my next question.  However, I don't see why it makes sense to 
conflate the use of the web storage API with a cache pattern.  It seems to 
me that the best way to do this would be to make the low-level API 
available and implement a cache on top of that.

On Monday, October 31, 2016 at 2:55:42 AM UTC-4, Peter Damoc wrote:
>
> On Mon, Oct 31, 2016 at 8:38 AM, David Andrews  > wrote:
>
>> I would really like to be able to use local storage in elm.  There have 
>> been several libraries that implement this, but none of them have been 
>> updated to elm 0.17.  So far the advice I've seen is just to wait, but I'm 
>> tired of waiting.
>>
>
> It's not really storage when you have a hard limit of 5MB of data. 
> persistent-cache <https://github.com/elm-lang/persistent-cache> will 
> probably end up covering the uses for that kind of functionality. 
>
> You should be using ports but if you really really want to use the 
> unreleased library, fork it, tag it with 1.0.0 and install it with 
> elm-github-install. 
>
>
> -- 
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] 0.17-compatible web storage

2016-10-30 Thread David Andrews
I would really like to be able to use local storage in elm.  There have 
been several libraries that implement this, but none of them have been 
updated to elm 0.17.  So far the advice I've seen is just to wait, but I'm 
tired of waiting.

The specification for web storage is here: https://www.w3.org/TR/webstorage/

This is the API I've devised based on that specification:
type StorageArea = LocalStorage | SessionStorage   
type StorageAction =   
Clear |
Update {   
key : String,  
oldValue : Maybe String,   
newValue : Maybe String
}  
type alias StorageEvent = {
action: StorageAction, 
url : String,  
storageArea : StorageArea  
}  
   
type SetItemError = QuotaExceededError 
   
length : StorageArea -> Task Never Int
   
key : StorageArea -> Int -> Task Never (Maybe String)  
   
getItem : StorageArea -> String -> Task Never (Maybe String)
   
setItem : StorageArea -> String -> String -> Task SetItemError ()   

removeItem : StorageArea -> String -> Task Never ()

clear : StorageArea -> Task Never ()   

sub : Sub StorageEvent

Firstly, what general feedback do you have on this API?
Secondly, I have a specific questions about sub:

   - Is there a naming convention for methods which return a subscription?
   - I notice that in some places, subscriptions are provided as methods (a 
   -> msg) -> Sub msg, rather than simply Sub a.  What is the reasoning 
   behind this, and is it a convention I'm expected to follow?

.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Sub.filterMap and Sub.concatMap

2016-10-30 Thread David Andrews
I found a discussion from May that has many thoughts on this.

https://groups.google.com/d/msg/elm-discuss/u-6aCwaJezo/fu-HMPy6CQAJ

My actual use case is that I'm looking into implementing a 0.17-compatible 
local storage library (which I'll post about in another thread), and would 
love to be able to write
eventsForKey : String -> Sub (Maybe String)
eventsForKey key =
events
|> Sub.filterMap (\x -> if x.key == key then Just x.newValue else 
Nothing)

which is implemented in terms of
events : Sub (Maybe String)


because I think it's a cleaner API than
eventsForKey : String -> (Maybe String -> msg) -> msg -> Sub msg
eventsForKey makeMsg noOp =
events
|> Sub.map (\x -> if x.key == key then makeMsg key.newValue else 
noOp)


On Monday, October 31, 2016 at 1:31:08 AM UTC-4, David Andrews wrote:
>
> Right now, the Platform.Sub library has a map function which allows for 
> transforming subscriptions.  However, the initial and modified 
> subscriptions will always produce the same number of messages.  Are there 
> plans to add filterMap and/or concatMap methods to Platform.Sub so that 
> the number of messages can be modified?
>
> A simple use case (not that you would actually do this) would be
> Time.every Time.second identity
> |> Sub.filterMap (\x -> if floor x % 2 == 0 then Just x else Nothing)
> to implement
> Time.every (2 * Time.second)
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Re: Sub.filterMap and Sub.concatMap

2016-10-30 Thread David Andrews
I found a discussion from May that has many thoughts on this.

https://groups.google.com/d/msg/elm-discuss/u-6aCwaJezo/fu-HMPy6CQAJ

My actual use case is that I'm looking into implementing a 0.17-compatible 
local storage library (which I'll post about in another thread), and would 
love to be able to write
eventsForKey : String -> Sub (Maybe String)
eventsForKey key =
events
|> Sub.filterMap (\x -> if x.key == key then Just x.newValue else 
Nothing)
which is implemented in terms of
events : Sub (Maybe String)
because I think it's a cleaner API than
eventsForKey : String -> (Maybe String -> msg) -> msg -> Sub msg
eventsForKey makeMsg noOp =
events
|> Sub.map (\x -> if x.key == key then makeMsg key.newValue else 
noOp)

On Monday, October 31, 2016 at 1:31:08 AM UTC-4, David Andrews wrote:
>
> Right now, the Platform.Sub library has a map function which allows for 
> transforming subscriptions.  However, the initial and modified 
> subscriptions will always produce the same number of messages.  Are there 
> plans to add filterMap and/or concatMap methods to Platform.Sub so that 
> the number of messages can be modified?
>
> A simple use case (not that you would actually do this) would be
> Time.every Time.second identity
> |> Sub.filterMap (\x -> if floor x % 2 == 0 then Just x else Nothing)
> to implement
> Time.every (2 * Time.second)
>
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Sub.filterMap and Sub.concatMap

2016-10-30 Thread David Andrews
Right now, the Platform.Sub library has a map function which allows for 
transforming subscriptions.  However, the initial and modified 
subscriptions will always produce the same number of messages.  Are there 
plans to add filterMap and/or concatMap methods to Platform.Sub so that the 
number of messages can be modified?

A simple use case (not that you would actually do this) would be
Time.every Time.second identity
|> Sub.filterMap (\x -> if floor x % 2 == 0 then Just x else Nothing)
to implement
Time.every (2 * Time.second)

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Outgoing port event ordering

2016-10-17 Thread David Andrews
The problem initially arose when I had two ports, one of which wrote to
local storage and the other of which closed the window.  Nothing was ever
written to local storage because the window closed first.  The reason I
went with two ports is because those actions are so conceptually different,
and if it were actually just for local storage I would have used a single
port.  If it were not for the fact that JavaScript processing ceases after
calling window.close, the current port implementation would have worked for
me.

On Oct 17, 2016 2:03 PM, "Leroy Campbell"  wrote:

> From what I can tell, port communication uses Cmd because interop with
> JavaScript isn't necessarily a request-response communication pattern
> (instead, port are pubsub).
>
> But I do have a question: *Is the underlying problem a need to coordinate
> access to a shared resource in JavaScript? *I ask because you mentioned
> localStorage in your initial message. I imagine you'd instead want to leave
> the coordination in Elm to take advantage of Elm's concurrency model
> (immutable data + message-passing) and have a single port to talk to
> JavaScript.
>
> On Monday, October 17, 2016 at 3:03:14 AM UTC-4, David Andrews wrote:
>>
>> In another discussion, I was pointed to http://faq.elm-community.or
>> g/17.html#what-is-the-difference-between-cmd-and-task, which sheds some
>> light on the issue, but also raises a few questions.
>>
>> Specifically:
>>
>>1. The article mentions that APIs generally expose Task in favor of
>>Cmd. Why is the port API a -> Cmd msg instead of a -> Task Never ()
>>or something like that?
>>2. Is there a recommended way to pass data to ports in order? I've
>>come up with the workaround of sending over only one port per update and
>>using Cmd.Extra.message to trigger additional updates immediately,
>>but I don't think it's very clean.
>>
>>
>> On Monday, October 17, 2016 at 2:39:01 AM UTC-4, Peter Damoc wrote:
>>>
>>> On Mon, Oct 17, 2016 at 8:02 AM, Janis Voigtländer <
>>> janis.voi...@gmail.com> wrote:
>>>
>>>> Peter, the problem in David’s case is that the actions he wants to
>>>> order execution of are port data sending, and there is no “something lower
>>>> level, like Tasks” for that. The only API available for port data
>>>> sending is Cmd-based.
>>>>
>>> Ooops... my bad. I should have looked more carefully.
>>>
>>>
>>>
>>> --
>>> There is NO FATE, we are the creators.
>>> blog: http://damoc.ro/
>>>
>> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Elm Discuss" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/elm-discuss/cSzJT2-g8Ss/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> elm-discuss+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [elm-discuss] Outgoing port event ordering

2016-10-17 Thread David Andrews
In another discussion, I was pointed to 
http://faq.elm-community.org/17.html#what-is-the-difference-between-cmd-and-task,
 
which sheds some light on the issue, but also raises a few questions.

Specifically:

   1. The article mentions that APIs generally expose Task in favor of Cmd. 
   Why is the port API a -> Cmd msg instead of a -> Task Never () or 
   something like that?
   2. Is there a recommended way to pass data to ports in order? I've come 
   up with the workaround of sending over only one port per update and using 
   Cmd.Extra.message to trigger additional updates immediately, but I don't 
   think it's very clean.
   

On Monday, October 17, 2016 at 2:39:01 AM UTC-4, Peter Damoc wrote:
>
> On Mon, Oct 17, 2016 at 8:02 AM, Janis Voigtländer  > wrote:
>
>> Peter, the problem in David’s case is that the actions he wants to order 
>> execution of are port data sending, and there is no “something lower level, 
>> like Tasks” for that. The only API available for port data sending is Cmd
>> -based.
>>
> Ooops... my bad. I should have looked more carefully. 
>
>
>
> -- 
> There is NO FATE, we are the creators.
> blog: http://damoc.ro/
>

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Outgoing port event ordering

2016-10-15 Thread David Andrews
When using Cmd.batch to send data over two ports, the ports receive the 
events in the same order regardless of the order in which they appear in 
the batch.  I would expect the events to occur in the order they appear in 
the batch.

Working example: https://daviddta.github.io/elm-port-order-bug/
Code: https://github.com/DavidDTA/elm-port-order-bug
Looking at the console, we see that port one always receives the event 
before port two.

As some motivation, consider two ports which both write to the same local 
storage key.  Without a guarantee on the ordering of events, the two 
subscriptions will race to write the key.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[elm-discuss] Order of outgoing port events

2016-10-15 Thread David Andrews
When using Cmd.batch to send data over two ports, the ports receive events 
in the same order regardless of the order in which they appear in the 
batch.  I think that they should occur in the order in which they appear in 
the batch instead.

Working example:
https://daviddta.github.io/elm-port-order-bug/
Code:
https://github.com/DavidDTA/elm-port-order-bug

Looking at the console, we see that port one always receives the event 
before port two.

To provide some motivation for this, consider two ports that write to the 
same local storage key.  Without any guarantees about the order of port 
event dispatch, we won't be able to know which write would win the race.

-- 
You received this message because you are subscribed to the Google Groups "Elm 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elm-discuss+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.