Skip to content

Instantly share code, notes, and snippets.

@jmitchell
Last active August 29, 2015 14:07
Show Gist options
  • Save jmitchell/db2b0e0c307ead910183 to your computer and use it in GitHub Desktop.
Save jmitchell/db2b0e0c307ead910183 to your computer and use it in GitHub Desktop.
Non-deterministic die roll
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