Documentation

Init.Data.Iterators.Consumers.Monadic.Access

inductive Std.Iterators.IterM.IsPlausibleNthOutputStep {α β : Type w} {m : Type w → Type w'} [Iterator α m β] :
NatIterM m βIterStep (IterM m β) βProp

it.IsPlausibleNthOutputStep n step is the proposition that according to the IsPlausibleStep relation, it is plausible that step returns the step in which the n-th value of it is emitted, or .done if it can plausibly terminate before emitting n values.

Instances For
    theorem Std.Iterators.IterM.not_isPlausibleNthOutputStep_yield {α β : Type w} {m : Type w → Type w'} [Iterator α m β] {n : Nat} {it it' : IterM m β} :
    class Std.Iterators.IteratorAccess (α : Type w) (m : Type w → Type w') {β : Type w} [Iterator α m β] :
    Type (max w w')

    IteratorAccess α m provides efficient implementations for random access or iterators that support it. it.nextAtIdx? n either returns the step in which the n-th value of it is emitted (necessarily of the form .yield _ _) or .done if it terminates before emitting the n-th value.

    For monadic iterators, the monadic effects of this operation may differ from manually iterating to the n-th value because nextAtIdx? can take shortcuts. By the signature, the return value is guaranteed to plausible in the sense of IterM.IsPlausibleNthOutputStep.

    This class is experimental and users of the iterator API should not explicitly depend on it.

    Instances
      @[inline]
      def Std.Iterators.IterM.nextAtIdx? {α : Type u_1} {m : Type u_1 → Type u_2} {β : Type u_1} [Iterator α m β] [IteratorAccess α m] (it : IterM m β) (n : Nat) :

      Returns the step in which it yields its n-th element, or .done if it terminates earlier. In contrast to step, this function will always return either .yield or .done but never a .skip step.

      For monadic iterators, the monadic effects of this operation may differ from manually iterating to the n-th value because nextAtIdx? can take shortcuts. By the signature, the return value is guaranteed to plausible in the sense of IterM.IsPlausibleNthOutputStep.

      This function is only available for iterators that explicitly support it by implementing the IteratorAccess typeclass.

      Equations
      Instances For
        @[inline]
        def Std.Iterators.IterM.atIdx? {α : Type u_1} {m : Type u_1 → Type u_2} {β : Type u_1} [Iterator α m β] [IteratorAccess α m] [Monad m] (it : IterM m β) (n : Nat) :
        m (Option β)

        Returns the n-th value emitted by it, or none if it terminates earlier.

        For monadic iterators, the monadic effects of this operation may differ from manually iterating to the n-th value because atIdx? can take shortcuts. By the signature, the return value is guaranteed to plausible in the sense of IterM.IsPlausibleNthOutputStep.

        This function is only available for iterators that explicitly support it by implementing the IteratorAccess typeclass.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For