Skip to content

Instantly share code, notes, and snippets.

@JoelQ
Last active July 27, 2024 09:23
Show Gist options
  • Save JoelQ/c93a8f6a81262ff12c93ab2ff859f8e5 to your computer and use it in GitHub Desktop.
Save JoelQ/c93a8f6a81262ff12c93ab2ff859f8e5 to your computer and use it in GitHub Desktop.
Turn an Elm random generator into task, allowing it to be chained with other side effects.
-- 0.19
randomToTask : Generator a -> Task x a
randomToTask generator =
Time.now
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << Time.posixToMillis)
-- 0.18
randomToTask : Generator a -> Task x a
randomToTask generator =
Time.now
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << round)
@andys8
Copy link

andys8 commented Oct 6, 2019

Interesting discussion regarding cmd chaining
https://gist.github.com/alpacaaa/13335246234042395813d97af029b10f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment