@@ -48,16 +48,16 @@ instance (α : Type w) (β : Type w) (n : Type x → Type x') [Monad n]
4848
4949@[always_inline, inline]
5050def Iter.Partial.instForIn' {α : Type w} {β : Type w} {n : Type x → Type x'} [Monad n]
51- [Iterator α Id β] [IteratorLoopPartial α Id n] :
51+ [Iterator α Id β] [IteratorLoop α Id n] :
5252 ForIn' n (Iter.Partial (α := α) β) β ⟨fun it out => it.it.IsPlausibleIndirectOutput out⟩ where
5353 forIn' it init f :=
54- IteratorLoopPartial.forInPartial (α := α) (m := Id) (n := n) (fun _ _ f c => f c.run)
54+ IteratorLoop.forIn (α := α) (m := Id) (n := n) (fun _ _ f c => f c.run) _
5555 it.it.toIterM init
5656 fun out h acc =>
5757 f out (Iter.isPlausibleIndirectOutput_iff_isPlausibleIndirectOutput_toIterM.mpr h) acc
5858
5959instance (α : Type w) (β : Type w) (n : Type x → Type x') [Monad n]
60- [Iterator α Id β] [IteratorLoopPartial α Id n] :
60+ [Iterator α Id β] [IteratorLoop α Id n] :
6161 ForIn n (Iter.Partial (α := α) β) β :=
6262 haveI : ForIn' n (Iter.Partial (α := α) β) β _ := Iter.Partial.instForIn'
6363 instForInOfForIn'
@@ -68,7 +68,7 @@ instance {m : Type x → Type x'}
6868 forM it f := forIn it PUnit.unit (fun out _ => do f out; return .yield .unit)
6969
7070instance {m : Type x → Type x'}
71- {α : Type w} {β : Type w} [Iterator α Id β] [IteratorLoopPartial α Id m] :
71+ {α : Type w} {β : Type w} [Iterator α Id β] [IteratorLoop α Id m] :
7272 ForM m (Iter.Partial (α := α) β) β where
7373 forM it f := forIn it PUnit.unit (fun out _ => do f out; return .yield .unit)
7474
@@ -77,11 +77,6 @@ Folds a monadic function over an iterator from the left, accumulating a value st
7777The accumulated value is combined with the each element of the list in order, using `f`.
7878
7979It is equivalent to `it.toList.foldlM`.
80-
81- This function requires a `Finite` instance proving that the iterator will finish after a finite
82- number of steps. If the iterator is not finite or such an instance is not available, consider using
83- `it.allowNontermination.foldM` instead of `it.foldM`. However, it is not possible to formally
84- verify the behavior of the partial variant.
8580-/
8681@[always_inline, inline]
8782def Iter.foldM {m : Type x → Type x'} [Monad m]
@@ -96,13 +91,12 @@ The accumulated value is combined with the each element of the list in order, us
9691
9792It is equivalent to `it.toList.foldlM`.
9893
99- This is a partial, potentially nonterminating, function. It is not possible to formally verify
100- its behavior. If the iterator has a `Finite` instance, consider using `IterM.foldM` instead.
94+ This function is deprecated. Instead of `it.allowNontermination.foldM`, use `it.foldM`.
10195-/
10296@[always_inline, inline]
10397def Iter.Partial.foldM {m : Type x → Type x'} [Monad m]
10498 {α : Type w} {β : Type w} {γ : Type x} [Iterator α Id β]
105- [IteratorLoopPartial α Id m] (f : γ → β → m γ)
99+ [IteratorLoop α Id m] (f : γ → β → m γ)
106100 (init : γ) (it : Iter.Partial (α := α) β) : m γ :=
107101 ForIn.forIn it init (fun x acc => ForInStep.yield <$> f acc x)
108102
@@ -111,11 +105,6 @@ Folds a function over an iterator from the left, accumulating a value starting w
111105The accumulated value is combined with the each element of the list in order, using `f`.
112106
113107It is equivalent to `it.toList.foldl`.
114-
115- This function requires a `Finite` instance proving that the iterator will finish after a finite
116- number of steps. If the iterator is not finite or such an instance is not available, consider using
117- `it.allowNontermination.fold` instead of `it.fold`. However, it is not possible to formally
118- verify the behavior of the partial variant.
119108-/
120109@[always_inline, inline]
121110def Iter.fold {α : Type w} {β : Type w} {γ : Type x} [Iterator α Id β]
@@ -129,12 +118,11 @@ The accumulated value is combined with the each element of the list in order, us
129118
130119It is equivalent to `it.toList.foldl`.
131120
132- This is a partial, potentially nonterminating, function. It is not possible to formally verify
133- its behavior. If the iterator has a `Finite` instance, consider using `IterM.fold` instead.
121+ This function is deprecated. Instead of `it.allowNontermination.fold`, use `it.fold`.
134122-/
135123@[always_inline, inline]
136124def Iter.Partial.fold {α : Type w} {β : Type w} {γ : Type x} [Iterator α Id β]
137- [IteratorLoopPartial α Id Id] (f : γ → β → γ)
125+ [IteratorLoop α Id Id] (f : γ → β → γ)
138126 (init : γ) (it : Iter.Partial (α := α) β) : γ :=
139127 ForIn.forIn (m := Id) it init (fun x acc => ForInStep.yield (f acc x))
140128
@@ -211,56 +199,53 @@ def Iter.findSomeM? {α β : Type w} {γ : Type x} {m : Type x → Type w'} [Mon
211199 | none => return .yield none
212200 | some fx => return .done (some fx))
213201
214- @[inline]
202+ @[inline, deprecated Iter.findSomeM? (since := "2025-10-21") ]
215203def Iter.Partial.findSomeM? {α β : Type w} {γ : Type x} {m : Type x → Type w'} [Monad m]
216- [Iterator α Id β] [IteratorLoopPartial α Id m] (it : Iter.Partial (α := α) β)
204+ [Iterator α Id β] [IteratorLoop α Id m] (it : Iter.Partial (α := α) β)
217205 (f : β → m (Option γ)) :
218206 m (Option γ) :=
219- ForIn.forIn it none (fun x _ => do
220- match ← f x with
221- | none => return .yield none
222- | some fx => return .done (some fx))
207+ it.it.findSomeM? f
223208
224209@[inline]
225210def Iter.findSome? {α β : Type w} {γ : Type x} [Iterator α Id β]
226211 [IteratorLoop α Id Id] (it : Iter (α := α) β) (f : β → Option γ) :
227212 Option γ :=
228213 Id.run (it.findSomeM? (pure <| f ·))
229214
230- @[inline]
215+ @[inline, deprecated Iter.findSome? (since := "2025-10-21") ]
231216def Iter.Partial.findSome? {α β : Type w} {γ : Type x} [Iterator α Id β]
232- [IteratorLoopPartial α Id Id] (it : Iter.Partial (α := α) β) (f : β → Option γ) :
217+ [IteratorLoop α Id Id] (it : Iter.Partial (α := α) β) (f : β → Option γ) :
233218 Option γ :=
234- Id.run ( it.findSomeM? (pure <| f ·))
219+ it. it.findSome? f
235220
236221@[inline]
237222def Iter.findM? {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α Id β]
238223 [IteratorLoop α Id m] (it : Iter (α := α) β) (f : β → m (ULift Bool)) :
239224 m (Option β) :=
240225 it.findSomeM? (fun x => return if (← f x).down then some x else none)
241226
242- @[inline]
227+ @[inline, deprecated Iter.findM? (since := "2025-10-21") ]
243228def Iter.Partial.findM? {α β : Type w} {m : Type w → Type w'} [Monad m] [Iterator α Id β]
244- [IteratorLoopPartial α Id m] (it : Iter.Partial (α := α) β) (f : β → m (ULift Bool)) :
229+ [IteratorLoop α Id m] (it : Iter.Partial (α := α) β) (f : β → m (ULift Bool)) :
245230 m (Option β) :=
246- it.findSomeM? ( fun x => return if (← f x).down then some x else none)
231+ it.it.findM? f
247232
248233@[inline]
249234def Iter.find? {α β : Type w} [Iterator α Id β] [IteratorLoop α Id Id]
250235 (it : Iter (α := α) β) (f : β → Bool) : Option β :=
251236 Id.run (it.findM? (pure <| .up <| f ·))
252237
253- @[inline]
254- def Iter.Partial.find? {α β : Type w} [Iterator α Id β] [IteratorLoopPartial α Id Id]
238+ @[inline, deprecated Iter.find? (since := "2025-10-21") ]
239+ def Iter.Partial.find? {α β : Type w} [Iterator α Id β] [IteratorLoop α Id Id]
255240 (it : Iter.Partial (α := α) β) (f : β → Bool) : Option β :=
256- Id.run ( it.findM? (pure <| .up <| f ·))
241+ it. it.find? f
257242
258- @[always_inline, inline, expose, inherit_doc IterM.size]
243+ @[always_inline, expose, inherit_doc IterM.size]
259244def Iter.size {α : Type w} {β : Type w} [Iterator α Id β] [IteratorSize α Id]
260245 (it : Iter (α := α) β) : Nat :=
261246 (IteratorSize.size it.toIterM).run.down
262247
263- @[always_inline, inline, inherit_doc IterM.Partial.size]
248+ @[always_inline, inherit_doc IterM.Partial.size]
264249def Iter.Partial.size {α : Type w} {β : Type w} [Iterator α Id β] [IteratorSizePartial α Id]
265250 (it : Iter (α := α) β) : Nat :=
266251 (IteratorSizePartial.size it.toIterM).run.down
0 commit comments