
9 Nov
2009
9 Nov
'09
5:07 p.m.
Hi all, while coding recently I came across the need for a strict mapM (that I indicidently use for m = MaybeT IO). I implementented this with the following simple code (it works for my use case): mapM' :: Monad m => (a-> m b) -> [a] -> m [b] mapM' _ [] = return [] mapM' f (x:xs) = do y <- f x ys <- y `seq` mapM' f xs return (y:ys) Now a couple of questions: 1. is it so "rare" to need such a beast? Why there isn't anything like that in standard libraries? 2. Is my implementation correct? 3. I've seen that mapM is implemented in base via sequence (which is in turn based on foldr). Is that any specific reason to prefer base implementation to mine? Thanks! Pao
5673
Age (days ago)
5673
Last active (days ago)
0 comments
1 participants
participants (1)
-
Paolo Losi