This module provides the iterator combinator IterM.append.
Given two iterators it₁ and it₂, it₁.append it₂ is an iterator that first outputs all values
of it₁ in order and then all values of it₂ in order.
Marble diagram:
it₁ ---a----b---c--⊥
it₂ --d--e--⊥
it₁.append it₂ ---a----b---c-----d--e--⊥
Termination properties:
Finiteinstance: only ifit₁andit₂are finiteProductiveinstance: only ifit₁andit₂are productive
Note: If it₁ is not finite, then it₁.append it₂ can be productive while it₂ is not.
The standard library does not provide a Productive instance for this case.
Performance:
This combinator incurs an additional O(1) cost with each output of it₁ and it₂.
Equations
- it₁.append it₂ = { internalState := Std.Iterators.Types.Append.fst it₁ it₂ }
Instances For
This combinator is only useful for advanced use cases.
Given an iterator it₂, IterM.Intermediate.appendSnd α₁ it₂ returns an iterator that behaves
exactly like it₂ but has the same type as it₁.append it₂ (after it₁ has been exhausted).
This is useful for constructing intermediate states of the append iterator.
Marble diagram:
it₂ --a--b--⊥
IterM.Intermediate.appendSnd α₁ it₂ --a--b--⊥
Termination properties:
Finiteinstance: only ifit₂and iterators of typeα₁are finiteProductiveinstance: only ifit₂and iterators of typeα₁are productive
Note: If iterators of type α₁ are not finite, then appendSnd α₁ it₂ can be productive
while it₂ is not. The standard library does not provide a Productive instance for this case.
Performance:
This combinator incurs an additional O(1) cost with each output of it₂.
Equations
- Std.IterM.Intermediate.appendSnd α₁ it₂ = { internalState := Std.Iterators.Types.Append.snd it₂ }
Instances For
- fstYield {m : Type w → Type w'} {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] {it₁' : IterM m β} {out : β} {it₁ : IterM m β} {it₂ : IterM m β} : it₁.IsPlausibleStep (IterStep.yield it₁' out) → PlausibleStep (it₁.append it₂) (IterStep.yield (it₁'.append it₂) out)
- fstSkip {m : Type w → Type w'} {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] {it₁' it₁ : IterM m β} {it₂ : IterM m β} : it₁.IsPlausibleStep (IterStep.skip it₁') → PlausibleStep (it₁.append it₂) (IterStep.skip (it₁'.append it₂))
- fstDone {m : Type w → Type w'} {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] {it₁ : IterM m β} {it₂ : IterM m β} : it₁.IsPlausibleStep IterStep.done → PlausibleStep (it₁.append it₂) (IterStep.skip (IterM.Intermediate.appendSnd α₁ it₂))
- sndYield {m : Type w → Type w'} {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] {it₂' : IterM m β} {out : β} {it₂ : IterM m β} : it₂.IsPlausibleStep (IterStep.yield it₂' out) → PlausibleStep (IterM.Intermediate.appendSnd α₁ it₂) (IterStep.yield (IterM.Intermediate.appendSnd α₁ it₂') out)
- sndSkip {m : Type w → Type w'} {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] {it₂' it₂ : IterM m β} : it₂.IsPlausibleStep (IterStep.skip it₂') → PlausibleStep (IterM.Intermediate.appendSnd α₁ it₂) (IterStep.skip (IterM.Intermediate.appendSnd α₁ it₂'))
- sndDone {m : Type w → Type w'} {β α₁ α₂ : Type w} [Iterator α₁ m β] [Iterator α₂ m β] {it₂ : IterM m β} : it₂.IsPlausibleStep IterStep.done → PlausibleStep (IterM.Intermediate.appendSnd α₁ it₂) IterStep.done
Instances For
Equations
- Std.Iterators.Types.Append.instFinitenessRelation = { Rel := Std.Iterators.Types.Append.Rel α₁ α₂ m β, wf := ⋯, subrelation := ⋯ }
Instances For
Equations
- One or more equations did not get rendered due to their size.