[Haskell-cafe] map in IO

2005-09-25 Thread Tom Hawkins
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?


-Tom

mapIO :: (a - IO b) - [a] - IO [b]
mapIO _ [] = return []
mapIO f (x:xs) = do y - f x
ys - mapIO f xs
return (y : ys)
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe


Re: [Haskell-cafe] map in IO

2005-09-25 Thread J. Garrett Morris
the similar function:

mapM :: Monad m = (a - m b) - [a] - m [b]

should do the trick for you, and is in the prelude.

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