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

Lifting bind into a monad. Generalized version of concatMap that works with a monadic predicate. Old and simpler specialized to list version had next type:
concatMapM :: Monad m => (a -> m [b]) -> [a] -> m [b]
Side note: previously it had type
concatMapM :: (Applicative q, Monad m, Traversable m)
=> (a -> q (m b)) -> m a -> q (m b)
Such signature didn't allow to use this function when traversed container type and type of returned by function-argument differed. Now you can use it like e.g.
concatMapM readFile files >>= putTextLn
Like concatMapM, but has its arguments flipped, so can be used instead of the common fmap concat $ forM pattern.