Skip to content

Commit db93fe1

Browse files
committed
refactor: move String.ofList to the Prelude (#12029)
This PR moves `String.ofList` to `Init.Prelude`. It is a function that the Lean kernel expects to be present and has special support for (when reducing string literals). By moving this to `Init.Prelude`, all declarations that are special to the kernel are in that single module. (cherry picked from commit 9167b13 and aac353c)
1 parent 2e2fe1e commit db93fe1

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Init/Data/String/Bootstrap.lean

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,6 @@ opaque getUTF8Byte (s : @& String) (n : Nat) (h : n < s.utf8ByteSize) : UInt8
123123

124124
end String.Internal
125125

126-
/--
127-
Creates a string that contains the characters in a list, in order.
128-
129-
Examples:
130-
* `['L', '∃', '∀', 'N'].asString = "L∃∀N"`
131-
* `[].asString = ""`
132-
* `['a', 'a', 'a'].asString = "aaa"`
133-
-/
134-
@[extern "lean_string_mk", expose]
135-
def String.ofList (data : List Char) : String :=
136-
⟨List.utf8Encode data,.intro data rfl⟩
137-
138126
@[extern "lean_string_mk", expose, deprecated String.ofList (since := "2025-10-30")]
139127
def String.mk (data : List Char) : String :=
140128
⟨List.utf8Encode data,.intro data rfl⟩

src/Init/Prelude.lean

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3470,6 +3470,18 @@ structure String where ofByteArray ::
34703470
attribute [extern "lean_string_to_utf8"] String.toByteArray
34713471
attribute [extern "lean_string_from_utf8_unchecked"] String.ofByteArray
34723472

3473+
/--
3474+
Creates a string that contains the characters in a list, in order.
3475+
3476+
Examples:
3477+
* `String.ofList ['L', '∃', '∀', 'N'] = "L∃∀N"`
3478+
* `String.ofList [] = ""`
3479+
* `String.ofList ['a', 'a', 'a'] = "aaa"`
3480+
-/
3481+
@[extern "lean_string_mk"]
3482+
def String.ofList (data : List Char) : String :=
3483+
⟨List.utf8Encode data, .intro data rfl⟩
3484+
34733485
/--
34743486
Decides whether two strings are equal. Normally used via the `DecidableEq String` instance and the
34753487
`=` operator.

0 commit comments

Comments
 (0)