[Haskell-cafe] Convert IO Int to Int

ptrash ptrash at web.de
Wed Jun 10 07:55:59 EDT 2009


Hi, 

I have tried on the console to write

x <- randomRIO(1,10)
:t x

Everythings fine and the type of x is
x :: Integer

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?
-- 
View this message in context: http://www.nabble.com/Convert-IO-Int-to-Int-tp23940249p23960652.html
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.



More information about the Haskell-Cafe mailing list