
25 Sep
2005
25 Sep
'05
3:45 p.m.
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)

25 Sep
25 Sep
4:10 p.m.
the similar function: mapM :: Monad m => (a -> m b) -> [a] -> m [b] should do the trick for you, and is in the prelude. /g
7181
Age (days ago)
7181
Last active (days ago)
1 comments
2 participants
participants (2)
-
J. Garrett Morris
-
Tom Hawkins