Add foldMapM to Data.Foldable
Andreas Abel
andreas.abel at ifi.lmu.de
Wed Dec 6 23:04:02 UTC 2017
+1.
If I remember correctly, then Henning Thielemann has suggested this as
the proper generalization of mapM_.
On 06.12.2017 15:28, Andrew Martin wrote:
> Several coworkers and myself have independently reinvented this function
> several times:
>
> foldMapM :: (Foldable g, Monoid b, Monad m) => (a -> m b) -> g a -> m b
> foldMapM f xs = foldlM (\b a -> mappend b <$> (f a)) mempty xs
>
> I would like to propose that this be added to Data.Foldable. We have the
> triplet foldr,foldl,foldMap in the Foldable typeclass itself, and
> Data.Foldable provides foldrM and foldlM. It would be nice to provide
> foldMapM for symmetry and because it seems to be useful in a variety of
> applications.
>
> --
> -Andrew Thaddeus Martin
>
>
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>
--
Andreas Abel <>< Du bist der geliebte Mensch.
Department of Computer Science and Engineering
Chalmers and Gothenburg University, Sweden
andreas.abel at gu.se
http://www.cse.chalmers.se/~abela/
More information about the Libraries
mailing list