
16 May
2005
16 May
'05
6:52 p.m.
S. Alexander Jacobson writes:
I don't think that is right. concatMap has definition
concatMap :: (a -> [b]) -> [a] -> [b] concatMap f xs = concat $ map f xs
Therefore:
msumMap :: (MonadPlus m) => (a1 -> m a) -> [a1] -> m a msumMap f list = msum $ fmap f list
Assuming your goal is to generalize by replacing (++) with mplus, you
want this:
msumMap f = foldr (mplus . f) mzero
It isn't in the standard libraries, so you'll have to define it
yourself.
--
David Menendez