I am developping in Haskell and had to use System.Random.
Now I have a IO [Int] and I would like to parse it to get the Int inside and then perform action on a list.
I did :
function :: IO [Int] -> [a] -> a
function (x:xs) list = (list !! x)
But I get an error on (x:xs) "Couldn't match expected type 'IO [Int]' with actual type '[a0]'.
How do I parse the IO [Int] to use the Int inside ?
IO
. – Willem Van Onsem Apr 7 at 20:33IO
thing to pass on to a pure consumer. But you can wrap a pure consumer to acceptIO
things (and returnIO
things), withfmap
or(>>=)
depending on whether the function returns anIO
thing or not. – Daniel Wagner Apr 8 at 20:05