[elm-discuss] What is the recommended way to clear a form on submit?

2017-06-18 Thread Mario Sangiorgio
I'm working on an application that has several forms, one for getting the 
user credential and some other to let the user insert some data.

Having forms in multiple pages is somehow more difficult than it should 
because of two known issues, both described 
here https://github.com/elm-lang/html/issues/105:

   - onInput and value don't interact well with each other, causing the 
   cursor to jump around
   - the virtual dom reuses forms component, making some values I entered 
   in one form leak into another

What is the recommended way of doing this?

My preference would be to always set value 

 to 
match what I have in the model. This would be clean and easy to understand 
but I'm not sure how safe it's to use it. The last thing I want is some 
clean code that has UX issues.

I could work around the virtual dom issues by abusing Html.Keyed, but that 
feels like an hack. And it would require even more hackery to make sure 
that I can reuse the same from multiple times.

Thanks,
Mario

-- 
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: Where for local functions

2017-06-18 Thread Igor Bukanov
In Idris the let is used for local variables while the where is for local 
functions. This strikes me as a very nice solution for a functional strict 
language. It separates the strict expressions that must be calculated before 
the main expressions from function helpers that may or may not be called after 
the main expression has started. This way the source follows the evaluation 
order avoiding an awkward jumping of reasoning when both functions and 
variables are mixed in the let clause.

-- 
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: Where for local functions

2017-06-18 Thread Francesco Orsenigo
Hi Igor,

my understanding is that `where` has not been implemented and will not be 
implemented to 1) keep the syntax lean and 2) ensure a consistent coding 
style.
I don't think Elm should have a `where` clause.
Coming from Haskell and physics, I instinctively liked the `where` syntax 
better, but as soon as I got some experience with Elm, using let..in became 
natural.
More in general, in my experience this kind of aesthetic preference comes 
largely from habit.




On Sunday, June 18, 2017 at 8:00:42 PM UTC+10, Igor Bukanov wrote:
>
> Hello,
>
> past discussions about adding the where clause to Elm typically suggested 
> to use it as syntax sugar for the let. 
>
> As far understand, this is how things are done in Haskell. Moreover, using 
> the where is very natural there as syntax order follows the lazy evaluation 
> strategy making it easier to reason about things.
>
> This does not work for Elm as the language is strict. Yet strictness is 
> only relevant for expressions, not function definitions. So perhaps 
> restricting the where only for local function definitions similarly to 
> Idris (strict language) may work for Elm?
>
> Compare:
>
> let triple x = x * x * x
> in
> List.map triple listOfInts
>
> versus
>
> List.map triple listOfInts
> where
> triple x = x * x * x
>
> For me the let version looks uglier as the syntax order is reverse of the 
> evaluation.
>
> For this reason I have noticed that I do not like to move complex lambdas 
> into local functions. Rather I wait until they become even more complex. 
> Then I make them top-level functions defined *after* the function that uses 
> them.
> 
> 
>
>

-- 
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] Mysterious failure to find packages during compilation

2017-06-18 Thread Ilias Van Peer
Yeah, this could be caused by "conflicting packages" - seems like you may 
have been using a different package that has a dependency on 
`elm-community/json-extra`, which uses the same module names as (and 
supersedes) `elm-community/elm-json-extra`.

Op zondag 18 juni 2017 05:08:38 UTC+2 schreef erik aker:
>
> Hi, I had a similar problem today and it turned out to be related to a 
> particular package in my elm-package.json. I noticed that after I added 
> that package, which was "elm-community/elm-json-extra": "2.3.0 <= v < 
> 3.0.0", that I would get this error about elm-lang/navigation. If I removed 
> this seemingly unrelated package from the list, the error goes away. I 
> also, like you, removed elm-stuff and tried again.
>

-- 
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] Where for local functions

2017-06-18 Thread Igor Bukanov
Hello,

past discussions about adding the where clause to Elm typically suggested to 
use it as syntax sugar for the let. 

As far understand, this is how things are done in Haskell. Moreover, using the 
where is very natural there as syntax order follows the lazy evaluation 
strategy making it easier to reason about things.

This does not work for Elm as the language is strict. Yet strictness is only 
relevant for expressions, not function definitions. So perhaps restricting the 
where only for local function definitions similarly to Idris (strict language) 
may work for Elm?

Compare:

let triple x = x * x * x
in
List.map triple listOfInts

versus

List.map triple listOfInts
where
triple x = x * x * x

For me the let version looks uglier as the syntax order is reverse of the 
evaluation.

For this reason I have noticed that I do not like to move complex lambdas into 
local functions. Rather I wait until they become even more complex. Then I make 
them top-level functions defined *after* the function that uses them.



-- 
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.