Loop consumers #
This module provides consumers that iterate over a given iterator, applying a certain user-supplied function in every iteration. Concretely, the following operations are provided:
ForIn
instancesIter.fold
, the analogue ofList.foldl
Iter.foldM
, the analogue ofList.foldlM
These operations are implemented using the IteratorLoop
and IteratorLoopPartial
typeclasses.
Equations
Equations
Folds a monadic function over an iterator from the left, accumulating a value starting with init
.
The accumulated value is combined with the each element of the list in order, using f
.
It is equivalent to it.toList.foldlM
.
This function requires a Finite
instance proving that the iterator will finish after a finite
number of steps. If the iterator is not finite or such an instance is not available, consider using
it.allowNontermination.foldM
instead of it.foldM
. However, it is not possible to formally
verify the behavior of the partial variant.
Equations
Instances For
Folds a monadic function over an iterator from the left, accumulating a value starting with init
.
The accumulated value is combined with the each element of the list in order, using f
.
It is equivalent to it.toList.foldlM
.
This is a partial, potentially nonterminating, function. It is not possible to formally verify
its behavior. If the iterator has a Finite
instance, consider using IterM.foldM
instead.
Equations
Instances For
Folds a function over an iterator from the left, accumulating a value starting with init
.
The accumulated value is combined with the each element of the list in order, using f
.
It is equivalent to it.toList.foldl
.
This function requires a Finite
instance proving that the iterator will finish after a finite
number of steps. If the iterator is not finite or such an instance is not available, consider using
it.allowNontermination.fold
instead of it.fold
. However, it is not possible to formally
verify the behavior of the partial variant.
Equations
Instances For
Folds a function over an iterator from the left, accumulating a value starting with init
.
The accumulated value is combined with the each element of the list in order, using f
.
It is equivalent to it.toList.foldl
.
This is a partial, potentially nonterminating, function. It is not possible to formally verify
its behavior. If the iterator has a Finite
instance, consider using IterM.fold
instead.