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:
ForIninstancesIter.fold, the analogue ofList.foldlIter.foldM, the analogue ofList.foldlM
These operations are implemented using the IteratorLoop and IteratorLoopPartial typeclasses.
A ForIn' instance for iterators. Its generic membership relation is not easy to use,
so this is not marked as instance. This way, more convenient instances can be built on top of it
or future library improvements will make it more comfortable.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
Equations
- One or more equations did not get rendered due to their size.
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
- Std.Iterators.Iter.foldM f init it = forIn it init fun (x : β) (acc : γ) => ForInStep.yield <$> f acc x
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
- Std.Iterators.Iter.Partial.foldM f init it = forIn it init fun (x : β) (acc : γ) => ForInStep.yield <$> f acc x
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
- Std.Iterators.Iter.fold f init it = forIn it init fun (x : β) (acc : γ) => ForInStep.yield (f acc x)
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.
Equations
- Std.Iterators.Iter.Partial.fold f init it = forIn it init fun (x : β) (acc : γ) => ForInStep.yield (f acc x)
Instances For
Returns true if the monadic predicate p returns true for
any element emitted by the iterator it.
O(|xs|). Short-circuits upon encountering the first match. The elements in it are
examined in order of iteration.
Equations
Instances For
Returns true if the pure predicate p returns true for
any element emitted by the iterator it.
O(|xs|). Short-circuits upon encountering the first match. The elements in it are
examined in order of iteration.
Equations
- Std.Iterators.Iter.any p it = (Std.Iterators.Iter.anyM (fun (x : β) => pure (p x)) it).run
Instances For
Returns true if the monadic predicate p returns true for
all elements emitted by the iterator it.
O(|xs|). Short-circuits upon encountering the first mismatch. The elements in it are
examined in order of iteration.
Equations
Instances For
Returns true if the pure predicate p returns true for
all elements emitted by the iterator it.
O(|xs|). Short-circuits upon encountering the first mismatch. The elements in it are
examined in order of iteration.
Equations
- Std.Iterators.Iter.all p it = (Std.Iterators.Iter.allM (fun (x : β) => pure (p x)) it).run
Instances For
Steps through the whole iterator, counting the number of outputs emitted.
Performance:
This function's runtime is linear in the number of steps taken by the iterator.
Instances For
Steps through the whole iterator, counting the number of outputs emitted.
Performance:
This function's runtime is linear in the number of steps taken by the iterator.
Instances For
Steps through the whole iterator, counting the number of outputs emitted.
Performance:
This function's runtime is linear in the number of steps taken by the iterator.
Instances For
Steps through the whole iterator, counting the number of outputs emitted.
Performance:
This function's runtime is linear in the number of steps taken by the iterator.