foldM

The foldM function is analogous to foldl, except that its result is encapsulated in a monad. Note that foldM works from left-to-right over the list arguments. This could be an issue where (>>) and the `folded function' are not commutative.
foldM f a1 [x1, x2, ..., xm]

==

do
a2 <- f a1 x1
a3 <- f a2 x2
...
f am xm
If right-to-left evaluation is required, the input list should be reversed. Note: foldM is the same as foldlM
A monadic strict left fold. Subject to fusion
A monadic strict left fold. Subject to fusion Since 0.3.0
Strict, monadic fold of the elements of a Producer
Control.Foldl.impurely foldM :: Monad m => FoldM a b -> Producer a m () -> m b
Like fold with monadic result.
Like fold, but monadic
Apply a strict monadic left FoldM to a lazy bytestring
Apply a strict monadic left FoldM to lazy text
A side-effecting left fold over an input stream. The input stream is fully consumed. See foldl. Example:
ghci> Streams.fromList [1..10] >>= Streams.foldM (x y -> return (x + y)) 0
55
A strict fold over the key-value records of a hash table in the ST monad. O(n).
See the documentation for this function in foldM.
See the documentation for this function in foldM.
See the documentation for this function in Data.HashTable.Class#v:foldM.
Strict, monadic fold of the elements of a Stream (Of a)
Control.Foldl.impurely foldM' :: Monad m => FoldM a b -> Stream (Of a) m r -> m (b, r)
Thus to accumulate the elements of a stream as a vector, together with a random element we might write:
>>> L.impurely S.foldM (liftA2 (,) L.vectorM L.random) $ each [1..10::Int] :: IO (Of (Vector Int, Maybe Int) ())
([1,2,3,4,5,6,7,8,9,10],Just 9) :> ()
O(n) Monadic fold
O(n) Monadic fold
O(n) Monadic fold
O(n) Monadic fold
Synonym for ofoldM
Monadic version of left fold, similar to foldM.
O(n) Monadic fold.
O(n) Monadic fold.
O(n) Monadic fold.
O(n) Monadic fold.
O(n) Monadic fold.