[Haskell-cafe] map in IO

Tom Hawkins tom at confluent.org
Sun Sep 25 15:45:23 EDT 2005

What is the best way to perform a map inside IO?  I defined the 
following function, but this must be common enough to warrant something 
in the standard library.  What am I missing?


mapIO :: (a -> IO b) -> [a] -> IO [b]
mapIO _ [] = return []
mapIO f (x:xs) = do y <- f x
                     ys <- mapIO f xs
                     return (y : ys)

More information about the Haskell-Cafe mailing list