Skip to content

Commit 7f6502e

Browse files
committed
Merge remote-tracking branch 'origin/main' into improve-platform-modules
2 parents c5aa34d + 5decd64 commit 7f6502e

File tree

34 files changed

+1402
-596
lines changed

34 files changed

+1402
-596
lines changed

crates/compiler/builtins/roc/Decode.roc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ DecodeError : [TooShort]
6060
## ```roc
6161
## expect
6262
## input = "\"hello\", " |> Str.to_utf8
63-
## actual = Decode.from_bytes_partial(input, Json.json)
63+
## actual = Decode.from_bytes_partial(input, Json.utf8)
6464
## expected = Ok("hello")
6565
##
6666
## actual.result == expected
@@ -133,7 +133,7 @@ decode_with = |bytes, @Decoder(decode), fmt| decode(bytes, fmt)
133133
## ```roc
134134
## expect
135135
## input = "\"hello\", " |> Str.to_utf8
136-
## actual = Decode.from_bytes_partial(input Json.json)
136+
## actual = Decode.from_bytes_partial(input Json.utf8)
137137
## expected = Ok("hello")
138138
##
139139
## actual.result == expected
@@ -147,7 +147,7 @@ from_bytes_partial = |bytes, fmt| decode_with(bytes, decoder, fmt)
147147
## ```roc
148148
## expect
149149
## input = "\"hello\", " |> Str.to_utf8
150-
## actual = Decode.from_bytes(input, Json.json)
150+
## actual = Decode.from_bytes(input, Json.utf8)
151151
## expected = Ok("hello")
152152
##
153153
## actual == expected

crates/compiler/builtins/roc/Encode.roc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ EncoderFormatting implements
7878
## # Appends the byte 42
7979
## custom_encoder = Encode.custom(\bytes, _fmt -> List.append(bytes, 42))
8080
##
81-
## actual = Encode.append_with([], custom_encoder, Core.json)
81+
## actual = Encode.append_with([], custom_encoder, Json.utf8)
8282
## expected = [42] # Expected result is a list with a single byte, 42
8383
##
8484
## actual == expected
@@ -93,7 +93,7 @@ append_with = |lst, @Encoder(do_encoding), fmt| do_encoding(lst, fmt)
9393
##
9494
## ```roc
9595
## expect
96-
## actual = Encode.append([], { foo: 43 }, Core.json)
96+
## actual = Encode.append([], { foo: 43 }, Json.utf8)
9797
## expected = Str.to_utf8("""{"foo":43}""")
9898
##
9999
## actual == expected
@@ -107,7 +107,7 @@ append = |lst, val, fmt| append_with(lst, to_encoder(val), fmt)
107107
## expect
108108
## foo_rec = { foo: 42 }
109109
##
110-
## actual = Encode.to_bytes(foo_rec, Core.json)
110+
## actual = Encode.to_bytes(foo_rec, Json.utf8)
111111
## expected = Str.to_utf8("""{"foo":42}""")
112112
##
113113
## actual == expected

src/base/Ident.zig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ const Ident = @This();
2020
pub const FROM_INT_DIGITS_METHOD_NAME = "from_int_digits";
2121
/// Method name for parsing decimals from digit lists - used by numeric literal type checking
2222
pub const FROM_DEC_DIGITS_METHOD_NAME = "from_dec_digits";
23+
/// Method name for addition - used by + operator desugaring
24+
pub const PLUS_METHOD_NAME = "plus";
2325

2426
/// The original text of the identifier.
2527
raw_text: []const u8,

src/build/builtin_compiler/main.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ fn replaceStrIsEmptyWithLowLevel(env: *ModuleEnv) !std.ArrayList(CIR.Def.Idx) {
155155
if (env.common.findIdent("Builtin.List.is_empty")) |list_is_empty_ident| {
156156
try low_level_map.put(list_is_empty_ident, .list_is_empty);
157157
}
158+
if (env.common.findIdent("Builtin.List.concat")) |list_concat_ident| {
159+
try low_level_map.put(list_concat_ident, .list_concat);
160+
}
158161
if (env.common.findIdent("list_get_unsafe")) |list_get_unsafe_ident| {
159162
try low_level_map.put(list_get_unsafe_ident, .list_get_unsafe);
160163
}

src/build/roc/Builtin.roc

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ Builtin := [].{
77
}
88

99
List := [ProvidedByCompiler].{
10-
len : List(_elem) -> U64
11-
is_empty : List(_elem) -> Bool
10+
len : List(_item) -> U64
11+
is_empty : List(_item) -> Bool
12+
concat : List(item), List(item) -> List(item)
1213

13-
first : List(elem) -> Try(elem, [ListWasEmpty])
14+
first : List(item) -> Try(item, [ListWasEmpty])
1415
first = |list| List.get(list, 0)
1516

16-
get : List(elem), U64 -> Try(elem, [ListWasEmpty])
17+
get : List(item), U64 -> Try(item, [ListWasEmpty])
1718
get = |list, index| if index < List.len(list) {
1819
Try.Ok(list_get_unsafe(list, index))
1920
} else {
@@ -25,9 +26,6 @@ Builtin := [].{
2526

2627
keep_if : List(a), (a -> Bool) -> List(a)
2728
keep_if = |_, _| []
28-
29-
concat : List(a), List(a) -> List(a)
30-
concat = |_, _| []
3129
}
3230

3331
Bool := [True, False].{
@@ -83,10 +81,10 @@ Builtin := [].{
8381

8482
Dict := [EmptyDict].{}
8583

86-
Set(elem) := [].{
87-
is_empty : Set(elem) -> Bool
84+
Set(item) := [].{
85+
is_empty : Set(item) -> Bool
8886

89-
is_eq : Set(elem), Set(elem) -> Bool
87+
is_eq : Set(item), Set(item) -> Bool
9088
is_eq = |_a, _b| Bool.False
9189
}
9290

@@ -342,4 +340,4 @@ Builtin := [].{
342340

343341
# Private top-level function for unsafe list access
344342
# This is a low-level operation that gets replaced by the compiler
345-
list_get_unsafe : List(elem), U64 -> elem
343+
list_get_unsafe : List(item), U64 -> item

0 commit comments

Comments
 (0)