Call this `foldMonoid` or `scanMonoid`, depending on whether it is emitting intermediate values. `foldM` is a bad name, since that usually [means something else](http://haddocks.fpcomplete.com/fp/7.4.2/20130922-179/base/Control-Monad.html#v:foldM).