Last active
August 29, 2015 13:57
-
-
Save jpaton/9800416 to your computer and use it in GitHub Desktop.
Generate a list of random things
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
newRandoms :: Random n => IO([n]) | |
newRandoms = do | |
gen <- newStdGen | |
let initial = random gen -- :: (n, StdGen) | |
pairs = initial : map (random . snd) pairs -- :: [(n, StdGen)] | |
mkRandomInts = map fst pairs -- :: [n] | |
return mkRandomInts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I uncomment those type annotations, GHC complains, and I don't understand why.