Random.generate : (a -> msg) -> Random.Generator a -> Cmd msg
Roll ->
(model, Random.generate NewFace (Random.int 1 6))
Or rather, update is still stateless (aka "pure") because the same arguments Roll and model produce the same result, a tuple of the model and a command.
Or rather, update is still stateless (aka "pure") because the same arguments Roll and model produce the same result, a tuple of the model and a command.Is that enough to maintain purity? Returning the same types is part of it, but if the values of those types are different each time, is that really purity?
And the second part -- does it matter either way?
--
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.
it might return (model, Cmd 1) or (model,Cmd 2)
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.
The official docs are harder to change than I'd like, but I welcome docs issues and PRs to my library:
https://github.com/mgold/elm-random-pcg
Eventually the RNG will replace core's, and hopefully I'll be able to update the docs at that time.