[Haskell-cafe] concatMap generalizes to msumMap?
zednenem at psualum.com
Mon May 16 18:52:38 EDT 2005
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
> 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
msumMap f = foldr (mplus . f) mzero
It isn't in the standard libraries, so you'll have to define it
David Menendez <zednenem at psualum.com> | "In this house, we obey the laws
<http://www.eyrie.org/~zednenem> | of thermodynamics!"
More information about the Haskell-Cafe