An iterator that sequentially emits values of type β. It may be finite
or infinite.
See the root module Std.Data.Iterators for a more comprehensive overview over the iterator
framework.
See Std.Data.Iterators.Producers for ways to iterate over common data structures.
By convention, the monadic iterator associated with an object can be obtained via dot notation.
For example, List.iterM IO creates an iterator over a list in the monad IO.
See Init.Data.Iterators.Consumers for ways to use an iterator. For example, it.toList will
convert a provably finite iterator it into a list and it.allowNontermination.toList will
do so even if finiteness cannot be proved. It is also always possible to manually iterate using
it.step, relying on the termination measures it.finitelyManySteps and it.finitelyManySkips.
See IterM for iterators that operate in a monad.
Internally, Iter β wraps an element of type α containing state information.
The type α determines the implementation of the iterator using a typeclass mechanism.
The concrete typeclass implementing the iterator is Iterator α m β.
When using combinators, α can become very complicated. It is an implicit parameter
of α so that the pretty printer will not print this large type by default. If a declaration
returns an iterator, the following will not work:
def x : Iter Nat := [1, 2, 3].iter
Instead the declaration type needs to be completely omitted:
def x := [1, 2, 3].iter -- if you want to ensure that `x` is an iterator emitting `Nat` def x := ([1, 2, 3].iter : Iter Nat)
Constructor
Std.Iterators.Iter.mk.{w}
Fields
internalState : α
Internal implementation detail of the iterator.