newbie:: getting random Ints
28 Mar 2002 01:05:47 -0500
total newbie to haskell, armed with "the craft of functional
i can't seem to generate random numbers. i have read this:
and searched the web and archives, and read thru Random.hs (mostly
over my head), but have been unable to get any combination of
getStdRandom randomR, etc. to work. even the example in the 98 report,
rollDice :: IO Int
rollDice = getStdRandom (randomR (1,6))
after loading the file, which makes me think i'm missing something!
TCFP has an example of how to do it yourself, but i can see that my
needs are more than met by Random.hs.
my various attempts all look a lot like this:
Main> getStdGen (random 5)
ERROR - Type error in application
*** Expression : getStdGen (random 5)
*** Term : getStdGen
*** Type : IO StdGen
*** Does not match : a -> b
could someone post an example of how to generate random integers
within a range?