foldM f a1 [x1, x2, ..., xm] == do a2 <- f a1 x1 a3 <- f a2 x2 ... f am xmIf right-to-left evaluation is required, the input list should be reversed. Note: foldM is the same as foldlM
Control.Foldl.impurely foldM :: Monad m => FoldM a b -> Producer a m () -> m b