:: (Applicative m, Foldable f, Monoid b) => (a -> m b) -> f a -> m b -package:Agda

Monadic version of foldMap
Map each element of a structure to an action, evaluate these actions from left to right, and concat the monoid results.
Polymorphic version of the concatMapM function.
>>> foldMapM @[Int] (Just . replicate 3) [1..3]
Just [1,1,1,2,2,2,3,3,3]
Extend foldMap to allow side effects. Internally, this is implemented using a strict left fold. This is used for performance reasons. It also necessitates that this function has a Monad constraint and not just an Applicative constraint. For more information, see https://github.com/commercialhaskell/rio/pull/99#issuecomment-394179757.
Polymorphic version of the concatMapA function.
>>> foldMapA @[Int] (Just . replicate 3) [1..3]
Just [1,1,1,2,2,2,3,3,3]