I have this code that suits me:
f :: [IO Int] -> IO [Int] f [] = return [] f (x:xs) = do a <- x as <- f xs return (a:as)
But I have a predefined way (msum?)
But I do not see how.
Any help would be appreciated. thanks
Yes, it is available in the standard library under the name sequence . It has a more general type than your f : Monad m => [ma] -> m [a] , since it works for any Monad , not just IO .
sequence
f
Monad m => [ma] -> m [a]
Monad
IO
You can find it yourself by looking for the type [IO a] -> IO [a] in Hoogle .
[IO a] -> IO [a]