[Haskell-cafe] Re: (liftM join .) . mapM
Maciej Piechotka
uzytkownik2 at gmail.com
Tue Dec 29 15:52:40 EST 2009
On Tue, 2009-12-29 at 18:20 +0000, Conor McBride wrote:
> Hi Tony
>
> On 29 Dec 2009, at 12:10, Tony Morris wrote:
>
> > Can (liftM join .) . mapM be improved?
> > (Monad m) => (a -> m [b]) -> [a] -> m [b]
>
> You can
>
> (a) generalize m from Monad to Applicative
> (b) generalize [b] to any Monoid
> (c) generalize [a] to f a for any Foldable f
>
> and write
>
> ala AppLift foldMap
>
> if you happen to have some of my usual kit. See below.
>
> Cheers
>
> Conor
What is benefit of it over:
concatMapA f = foldr (liftA2 mappend . f) (pure mempty)
Regards
More information about the Haskell-Cafe
mailing list