26 Sep
2005
26 Sep
'05
3:45 a.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)
26 Sep
26 Sep
4:10 a.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
7359
Age (days ago)
7359
Last active (days ago)
1 comments
2 participants
participants (2)
-
J. Garrett Morris -
Tom Hawkins