-
-
Save TwistingTwists/3cecbb373a76e4e4f19250fd1b423b05 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 0.19 | |
randomToTask : Generator a -> Task Never a | |
randomToTask generator = | |
Time.now | |
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << Time.posixToMillis) | |
-- 0.18 | |
randomToTask : Generator a -> Task Never a | |
randomToTask generator = | |
Time.now | |
|> Task.map (Tuple.first << Random.step generator << Random.initialSeed << round) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment