Skip to content

Instantly share code, notes, and snippets.

@siers
Created November 6, 2013 11:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save siers/7334870 to your computer and use it in GitHub Desktop.
Save siers/7334870 to your computer and use it in GitHub Desktop.
I did some monad magic, and it actually worked.
import Control.Monad.Loops
import System.Random
specifify :: Int -> Int
specifify i = i `mod` 100
use :: (Int, StdGen) -> IO StdGen
use (i, g) = (putStrLn $ "New rand int: " ++ show (specifify i)) >> return g
main = getStdGen >>= iterateM_ (use . random)
@siers
Copy link
Author

siers commented Nov 6, 2013

$ ./monad..hard.monad | head
New rand int: 0
New rand int: 40
New rand int: 12
New rand int: 86
New rand int: 46
New rand int: 32
New rand int: 54
New rand int: 15
New rand int: 18
New rand int: 33

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