At the risk of necroposting, just thought I'd mention that today is the day 
that I first needed Random-ness in elm. After accidentally reading the old 
Random docs, encountering and wondering about the function signatures that 
pass the random seed around, having the lightbulb moment about this being 
related to FP purity, I then read the latest (0.17) docs where "generate" 
has been renamed to "step", and the new "generate" does the Cmd tag thing, 
with no seed curation. Well then of course I was de-railed and was 
wondering where the seed state lived until I read this post.

Long story short, I think this is an important point to have in the 
docs/Guide. People with an FP background get thrown by the lack of purity 
of generate, and people who are new to FP probably wonder why they have to 
worry about dealing with the seed when using 'step'; they are used to just 
calling Random.Next() or something. As long as this thread is google-able 
it will be OK, but I wonder if there is a nice way to outline this stuff in 
the docs?


On Monday, 16 May 2016 06:17:40 UTC+1, Richard Feldman wrote:
>
> Elm doesn't have "no side effects", it has managed side effects. But if 
>> there's no Task or Cmd or Sub in the type, you can be sure that the 
>> function is side-effect free. This way, when there's problems with 
>> side-effects, it's easy to track down which functions are causing them, 
>> since you know pure ones will never be the problem.
>>
>
> To be totally clear on this, even if the function returns a Task or Cmd or 
> Sub, the function is still side-effect 
> <https://en.wikipedia.org/wiki/Side_effect_(computer_science)> free! It's 
> just returning a value. You really can't write an Elm function that has 
> side effects (without involving the Debug or Native modules), and that 
> includes functions that return Task, Cmd, or Sub.
>
> As it happens, the purpose of the values Cmd, Task, and Sub is to describe 
> various effects that we'd like Elm's runtime to carry out eventually, but 
> they are still just values nonetheless. Instantiating them is precisely as 
> side-effectful as instantiating a String. ;)
>

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

Reply via email to