Last active
August 29, 2015 14:07
-
-
Save jmitchell/db2b0e0c307ead910183 to your computer and use it in GitHub Desktop.
Non-deterministic die roll
This file contains 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
module Main | |
import Effect.Random | |
import Effect.StdIO | |
import Effect.System | |
getSeed : { [SYSTEM] } Eff Integer | |
getSeed = do case index' 1 !getArgs of | |
Nothing => pure $ cast !time | |
Just t => pure $ cast t | |
computeAndDisplay : Integer -> { [RND, STDIO] } Eff () | |
computeAndDisplay seed = do srand seed | |
x <- rndInt 1 7 | |
putStrLn $ show x ++ " (seed " ++ show seed ++ ")" | |
rollDie : { [RND, STDIO, SYSTEM] } Eff () | |
rollDie = do computeAndDisplay !getSeed | |
main : IO () | |
main = run rollDie |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment