@[unbox]
structure
Std.Iterators.Types.Attach
(α : Type w)
(m : Type w → Type w')
{β : Type w}
[Iterator α m β]
(P : β → Prop)
:
Type w
Internal state of the attachWith
combinator. Do not depend on its internals.
- inner : IterM m β
- invariant (out : β) : self.inner.IsPlausibleIndirectOutput out → P out
Instances For
@[inline]
def
Std.Iterators.Types.Attach.Monadic.modifyStep
{α : Type w}
{m : Type w → Type w'}
{β : Type w}
[Iterator α m β]
{P : β → Prop}
(it : IterM m { out : β // P out })
(step : it.internalState.inner.Step)
:
Equations
- Std.Iterators.Types.Attach.Monadic.modifyStep it ⟨Std.Iterators.IterStep.yield it' out, h⟩ = Std.Iterators.IterStep.yield { internalState := { inner := it', invariant := ⋯ } } ⟨out, ⋯⟩
- Std.Iterators.Types.Attach.Monadic.modifyStep it ⟨Std.Iterators.IterStep.skip it', h⟩ = Std.Iterators.IterStep.skip { internalState := { inner := it', invariant := ⋯ } }
- Std.Iterators.Types.Attach.Monadic.modifyStep it ⟨Std.Iterators.IterStep.done, property⟩ = Std.Iterators.IterStep.done
Instances For
def
Std.Iterators.Types.Attach.instProductivenessRelation
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
[Iterator α m β]
[Productive α m]
{P : β → Prop}
:
ProductivenessRelation (Attach α m P) m
Equations
- One or more equations did not get rendered due to their size.
Instances For
instance
Std.Iterators.Types.Attach.instProductive
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
[Iterator α m β]
[Productive α m]
{P : β → Prop}
:
Productive (Attach α m P) m
instance
Std.Iterators.Types.Attach.instIteratorLoop
{n : Type w → Type u_1}
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
[Monad n]
{P : β → Prop}
[Iterator α m β]
[MonadLiftT m n]
:
IteratorLoop (Attach α m P) m n
instance
Std.Iterators.Types.Attach.instIteratorLoopPartial
{n : Type w → Type u_1}
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
[Monad n]
{P : β → Prop}
[Iterator α m β]
[MonadLiftT m n]
:
IteratorLoopPartial (Attach α m P) m n
instance
Std.Iterators.Types.instIteratorSizeAttachSubtype
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
{P : β → Prop}
[Iterator α m β]
[IteratorSize α m]
:
IteratorSize (Attach α m P) m
Equations
- Std.Iterators.Types.instIteratorSizeAttachSubtype = { size := fun (it : Std.IterM m { out : β // P out }) => Std.Iterators.IteratorSize.size it.internalState.inner }
instance
Std.Iterators.Types.instIteratorSizePartialAttachSubtype
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
{P : β → Prop}
[Iterator α m β]
[IteratorSizePartial α m]
:
IteratorSizePartial (Attach α m P) m
Equations
- Std.Iterators.Types.instIteratorSizePartialAttachSubtype = { size := fun (it : Std.IterM m { out : β // P out }) => Std.Iterators.IteratorSizePartial.size it.internalState.inner }
@[inline]
def
Std.Iterators.IterM.attachWith
{α β : Type w}
{m : Type w → Type w'}
[Monad m]
[Iterator α m β]
(it : IterM m β)
(P : β → Prop)
(h : ∀ (out : β), it.IsPlausibleIndirectOutput out → P out)
:
“Attaches” individual proofs to an iterator of values that satisfy a predicate P
, returning an
iterator with values in the corresponding subtype { x // P x }
.
Termination properties:
Finite
instance: only if the base iterator is finiteProductive
instance: only if the base iterator is productive