On 10 Jun 2009, at 12:55 pm, ptrash wrote:



Now I have tried to write a Method which gives me a Number of random numbers
the same way but it doesn't work.

randomList :: Int -> [Integer]
randomList 0 = []
randomList n = do
                             r <- randomRIO (1, 10)
                             r:randomList(n-1)

It says Couldn't match expected type `IO t' against inferred type `[t]' r <- randomRIO (1,10) causes an error. But why does it work on the console?
Is there a way to solve it another way?


I had the same problem a while back, the thread is here
http://www.mail-archive.com/haskell-cafe@haskell.org/msg46194.html

the console uses IO already, so it's not a problem there. I ended up learning about the >>= operator, and that helped a lot. Anyway, lots of helpful links in that mail thread.

Iain

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to