Created
November 6, 2013 11:51
-
-
Save siers/7334870 to your computer and use it in GitHub Desktop.
I did some monad magic, and it actually worked.
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
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ ./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