
+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@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@gu.se http://www.cse.chalmers.se/~abela/