
16 Jan
2008
16 Jan
'08
5:29 a.m.
On Tue, Jan 15, 2008 at 08:31:48PM +0000, Conor McBride wrote:
And now we're home!
parpSplat :: (Applicative parp, Foldable f, Monoid splat) => (x -> parp splat) -> f x -> parp splat parpSplat = ala AMonoid foldMap -- modulo AMonoid aMonoid foldMap
Unfolding these definitions, a shorter (but less scenic) route to this particular destination is: foldMapM :: (Monad m, Foldable t, Monoid v) => (a -> m v) -> t a -> m v foldMapM f = Data.Foldable.foldr mappend_f (return mempty) where mappend_f x y = liftM2 mappend (f x) y foldMapA :: (Applicative f, Foldable t, Monoid v) => (a -> f v) -> t a -> f v foldMapA f = Data.Foldable.foldr mappend_f (pure mempty) where mappend_f x y = mappend <$> f x <*> y