Skip to content

Commit 62e9be9

Browse files
committed
chore: rename Stream to Std.Stream
1 parent d88e417 commit 62e9be9

File tree

12 files changed

+44
-27
lines changed

12 files changed

+44
-27
lines changed

src/Init/Data/Stream.lean

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import Init.Data.Slice.Array.Basic
1313

1414
public section
1515

16+
namespace Std
17+
1618
/-!
1719
Remark: we considered using the following alternative design
1820
```
@@ -112,3 +114,19 @@ instance : Stream Std.Range Nat where
112114
some (r.start, { r with start := r.start + r.step })
113115
else
114116
none
117+
118+
end Std
119+
120+
@[deprecated Std.Stream (since := "2025-10-01")]
121+
abbrev Stream := Std.Stream
122+
123+
-- Not deprecated to avoid bootstrapping annoyances
124+
abbrev Stream.next? {stream : Type u} {value : outParam (Type v)} [self : Std.Stream stream value] :
125+
stream → Option (value × stream) := Std.Stream.next?
126+
127+
@[deprecated Std.ToStream (since := "2025-10-01")]
128+
abbrev ToStream := Std.ToStream
129+
130+
-- Not deprecated to avoid bootstrapping annoyances
131+
abbrev ToStream.toStream {collection : Type u} {stream : outParam (Type u)}
132+
[self : Std.ToStream collection stream] : collection → stream := Std.ToStream.toStream

src/Init/Data/String/Stream.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ prelude
99
public import Init.Data.String.Basic
1010
public import Init.Data.Stream
1111

12-
public instance : Stream Substring Char where
12+
public instance : Std.Stream Substring Char where
1313
next? s :=
1414
if s.startPos < s.stopPos then
1515
some (s.str.get s.startPos, { s with startPos := s.str.next s.startPos })

src/Init/Data/Vector/Basic.lean

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ module
88

99
prelude
1010
public meta import Init.Coe
11-
-- public import Init.Data.Stream
1211
public import Init.Data.Array.Lemmas
1312
public import Init.Data.Array.MapIdx
1413
public import Init.Data.Array.InsertIdx

src/Init/Data/Vector/Stream.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace Vector
1414
/-! ### ToStream instance -/
1515

1616
@[no_expose]
17-
public instance : ToStream (Vector α n) (Subarray α) where
17+
public instance : Std.ToStream (Vector α n) (Subarray α) where
1818
toStream xs := xs.toArray[*...*]
1919

2020
end Vector

src/Lean/Elab/Do.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,9 +1540,9 @@ mutual
15401540
```
15411541
into
15421542
```
1543-
let s := toStream ys
1543+
let s := Std.toStream ys
15441544
for x in xs do
1545-
match Stream.next? s with
1545+
match Std.Stream.next? s with
15461546
| none => break
15471547
| some (y, s') =>
15481548
s := s'
@@ -1560,11 +1560,11 @@ mutual
15601560
withFreshMacroScope do
15611561
/- Recall that `@` (explicit) disables `coeAtOutParam`.
15621562
We used `@` at `Stream` functions to make sure `resultIsOutParamSupport` is not used. -/
1563-
let toStreamApp ← withRef ys `(@toStream _ _ _ $ys)
1563+
let toStreamApp ← withRef ys `(@Std.toStream _ _ _ $ys)
15641564
let auxDo ←
15651565
`(do let mut s := $toStreamApp:term
15661566
for $doForDecls:doForDecl,* do
1567-
match @Stream.next? _ _ _ s with
1567+
match @Std.Stream.next? _ _ _ s with
15681568
| none => break
15691569
| some ($y, s') =>
15701570
s := s'

src/Lean/Parser/Do.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ def doForDecl := leading_parser
157157
`break` and `continue` are supported inside `for` loops.
158158
`for x in e, x2 in e2, ... do s` iterates of the given collections in parallel,
159159
until at least one of them is exhausted.
160-
The types of `e2` etc. must implement the `ToStream` typeclass.
160+
The types of `e2` etc. must implement the `Std.ToStream` typeclass.
161161
-/
162162
@[builtin_doElem_parser] def doFor := leading_parser
163163
"for " >> sepBy1 doForDecl ", " >> "do " >> doSeq

tests/bench/workspaceSymbolsNewRanges.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def consts := ["_private.«external:file:///Users/paul/code/lean4/tests/bench/wo
478478
"Std.Slice.casesOn",
479479
"_private.Init.Data.Vector.Lemmas.0.Vector.forall_mem_append._simp_1_2",
480480
"Std.PRange.forIn'_eq_match.match_3",
481-
"ToStream.casesOn",
481+
"Std.ToStream.casesOn",
482482
"Lean.Level.PP.Result.leaf.inj",
483483
"Lean.PrettyPrinter.Parenthesizer.Context._sizeOf_1",
484484
"Std.Format.tag",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
forErrors.lean:3:29-3:30: error: failed to synthesize
2-
ToStream α ?m
2+
Std.ToStream α ?m
33

44
Hint: Additional diagnostic information may be available using the `set_option diagnostics true` command.

tests/lean/run/1017.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
namespace Stream
1+
namespace Std.Stream
22

3-
variable [Stream ρ τ] (s : ρ)
3+
variable [Std.Stream ρ τ] (s : ρ)
44

55
def take (s : ρ) : Nat → List τ × ρ
66
| 0 => ([], s)
@@ -52,4 +52,4 @@ def mwe [Stream ρ τ] (acc : α) : {l : ρ // isFinite l} → α
5252
mwe acc ⟨xs, by sorry
5353
termination_by l => l
5454

55-
end Stream
55+
end Std.Stream

tests/lean/run/streamEqIssue.lean

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
@[simp] def Stream.hasLength [Stream stream value] (n : Nat) (s : stream) : Bool :=
1+
@[simp] def Std.Stream.hasLength [Stream stream value] (n : Nat) (s : stream) : Bool :=
22
match n, Stream.next? s with
33
| 0, none => true
44
| n + 1, some (_, s') => hasLength n s'
55
| _, _ => false
66

7-
#check @Stream.hasLength.eq_1
8-
#check @Stream.hasLength.eq_2
9-
#check @Stream.hasLength.eq_3
7+
#check @Std.Stream.hasLength.eq_1
8+
#check @Std.Stream.hasLength.eq_2
9+
#check @Std.Stream.hasLength.eq_3

0 commit comments

Comments
 (0)