Skip to content

Commit f5b08f2

Browse files
authored
Merge branch 'main' into zihang/improve-copy
2 parents ffb2b40 + 4ebbe4f commit f5b08f2

20 files changed

+164
-188
lines changed

array/pkg.generated.mbti

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
package "moonbitlang/core/array"
33

44
import(
5-
"moonbitlang/core/bytes"
65
"moonbitlang/core/quickcheck"
76
"moonbitlang/core/string"
87
)
@@ -15,7 +14,7 @@ fn[A, B, C] zip_with(Array[A], Array[B], (A, B) -> C raise?) -> Array[C] raise?
1514
// Types and methods
1615
fn[T] FixedArray::all(Self[T], (T) -> Bool raise?) -> Bool raise?
1716
fn[T] FixedArray::any(Self[T], (T) -> Bool raise?) -> Bool raise?
18-
fn FixedArray::blit_from_bytesview(Self[Byte], Int, @bytes.View) -> Unit
17+
fn FixedArray::blit_from_bytesview(Self[Byte], Int, BytesView) -> Unit
1918
fn[T : Eq] FixedArray::contains(Self[T], T) -> Bool
2019
fn[T] FixedArray::copy(Self[T]) -> Self[T]
2120
fn[T] FixedArray::each(Self[T], (T) -> Unit raise?) -> Unit raise?
@@ -26,7 +25,7 @@ fn[A, B] FixedArray::foldi(Self[A], init~ : B, (Int, B, A) -> B raise?) -> B rai
2625
fn[T] FixedArray::from_array(Array[T]) -> Self[T]
2726
fn[T] FixedArray::from_iter(Iter[T]) -> Self[T]
2827
fn[T : Compare] FixedArray::is_sorted(Self[T]) -> Bool
29-
fn FixedArray::join(Self[String], @string.View) -> String
28+
fn FixedArray::join(Self[String], StringView) -> String
3029
fn[A] FixedArray::last(Self[A]) -> A?
3130
fn[T] FixedArray::makei(Int, (Int) -> T raise?) -> Self[T] raise?
3231
fn[T, U] FixedArray::map(Self[T], (T) -> U raise?) -> Self[U] raise?
@@ -52,7 +51,7 @@ impl[X : @quickcheck.Arbitrary] @quickcheck.Arbitrary for FixedArray[X]
5251

5352
fn[A, B] Array::filter_map(Self[A], (A) -> B? raise?) -> Self[B] raise?
5453
fn[T] Array::from_iter(Iter[T]) -> Self[T]
55-
fn[A : @string.ToStringView] Array::join(Self[A], @string.View) -> String
54+
fn[A : @string.ToStringView] Array::join(Self[A], StringView) -> String
5655
fn[A] Array::last(Self[A]) -> A?
5756
fn[T] Array::push_iter(Self[T], Iter[T]) -> Unit
5857
fn[T] Array::shuffle(Self[T], rand~ : (Int) -> Int) -> Self[T]
@@ -82,7 +81,7 @@ fn[A, B] ArrayView::fold(Self[A], init~ : B, (B, A) -> B raise?) -> B raise?
8281
fn[A, B] ArrayView::foldi(Self[A], init~ : B, (Int, B, A) -> B raise?) -> B raise?
8382
fn[A] ArrayView::iter(Self[A]) -> Iter[A]
8483
fn[A] ArrayView::iter2(Self[A]) -> Iter2[Int, A]
85-
fn[A : @string.ToStringView] ArrayView::join(Self[A], @string.View) -> String
84+
fn[A : @string.ToStringView] ArrayView::join(Self[A], StringView) -> String
8685
fn[T, U] ArrayView::map(Self[T], (T) -> U raise?) -> Array[U] raise?
8786
#deprecated
8887
fn[T] ArrayView::map_inplace(Self[T], (T) -> T raise?) -> Unit raise?

buffer/pkg.generated.mbti

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
// Generated using `moon info`, DON'T EDIT IT
22
package "moonbitlang/core/buffer"
33

4-
import(
5-
"moonbitlang/core/bytes"
6-
"moonbitlang/core/string"
7-
)
8-
94
// Values
105
fn from_array(Array[Byte]) -> Buffer
116

@@ -26,7 +21,7 @@ fn Buffer::reset(Self) -> Unit
2621
fn Buffer::to_bytes(Self) -> Bytes
2722
fn Buffer::write_byte(Self, Byte) -> Unit
2823
fn Buffer::write_bytes(Self, Bytes) -> Unit
29-
fn Buffer::write_bytesview(Self, @bytes.View) -> Unit
24+
fn Buffer::write_bytesview(Self, BytesView) -> Unit
3025
fn Buffer::write_char_utf16be(Self, Char) -> Unit
3126
fn Buffer::write_char_utf16le(Self, Char) -> Unit
3227
fn Buffer::write_char_utf8(Self, Char) -> Unit
@@ -41,10 +36,10 @@ fn Buffer::write_int_le(Self, Int) -> Unit
4136
fn Buffer::write_iter(Self, Iter[Byte]) -> Unit
4237
fn[A : Leb128] Buffer::write_leb128(Self, A) -> Unit
4338
fn Buffer::write_object(Self, &Show) -> Unit
44-
fn Buffer::write_string_utf16be(Self, @string.View) -> Unit
39+
fn Buffer::write_string_utf16be(Self, StringView) -> Unit
4540
#alias(write_stringview, deprecated)
46-
fn Buffer::write_string_utf16le(Self, @string.View) -> Unit
47-
fn Buffer::write_string_utf8(Self, @string.View) -> Unit
41+
fn Buffer::write_string_utf16le(Self, StringView) -> Unit
42+
fn Buffer::write_string_utf8(Self, StringView) -> Unit
4843
fn Buffer::write_uint64_be(Self, UInt64) -> Unit
4944
fn Buffer::write_uint64_le(Self, UInt64) -> Unit
5045
fn Buffer::write_uint_be(Self, UInt) -> Unit

builtin/failure.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
/// }
3333
/// @json.inspect(err, content=["Failure", "Test assertion failed"])
3434
/// ```
35-
pub(all) suberror Failure String derive(ToJson(style="flat"), Show)
35+
pub(all) suberror Failure String derive(ToJson, Show)
3636
3737
///|
3838
/// Raises a `Failure` error with a given message and source location.

builtin/guard_feature_test.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ enum Expr {
2020
Div(Expr, Expr)
2121
Lit(Int)
2222
Var(String)
23-
} derive(Show, ToJson(style="flat"), Eq)
23+
} derive(Show, ToJson, Eq)
2424

2525
///|
2626
fn simplify(e : Expr) -> Expr {

builtin/intrinsics.mbt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ pub fn Int::lnot(self : Int) -> Int = "%i32_lnot"
348348
/// let y = 0xAA // 10101010
349349
/// inspect(x & y, content="160") // 10100000 = 160
350350
/// ```
351-
pub fn Int::land(self : Int, other : Int) -> Int = "%i32_land"
351+
pub impl BitAnd for Int with land(self : Int, other : Int) -> Int = "%i32_land"
352352

353353
///|
354354
/// Performs a bitwise OR operation between two 32-bit integers. For each bit
@@ -370,7 +370,7 @@ pub fn Int::land(self : Int, other : Int) -> Int = "%i32_land"
370370
/// let y = 0x0F0F // 0000_1111_0000_1111
371371
/// inspect(x | y, content="65535") // 1111_1111_1111_1111 = 65535
372372
/// ```
373-
pub fn Int::lor(self : Int, other : Int) -> Int = "%i32_lor"
373+
pub impl BitOr for Int with lor(self : Int, other : Int) -> Int = "%i32_lor"
374374

375375
///|
376376
/// Performs a bitwise XOR operation between two integers.
@@ -391,7 +391,7 @@ pub fn Int::lor(self : Int, other : Int) -> Int = "%i32_lor"
391391
/// inspect(x ^ y, content="65535") // 1111_1111_1111_1111
392392
/// inspect(x ^ x, content="0") // XOR with self gives 0
393393
/// ```
394-
pub fn Int::lxor(self : Int, other : Int) -> Int = "%i32_lxor"
394+
pub impl BitXOr for Int with lxor(self : Int, other : Int) -> Int = "%i32_lxor"
395395

396396
///|
397397
/// Performs a left shift operation on a 32-bit integer. Shifts each bit in the
@@ -1901,7 +1901,7 @@ pub impl Compare for UInt with compare(self, other) = "%u32.compare"
19011901
/// let b = 0xFF00U // 1111_1111_0000_0000
19021902
/// inspect(a & b, content="61440") // 1111_0000_0000_0000 = 61440
19031903
/// ```
1904-
pub fn UInt::land(self : UInt, other : UInt) -> UInt = "%u32.bitand"
1904+
pub impl BitAnd for UInt with land(self : UInt, other : UInt) -> UInt = "%u32.bitand"
19051905

19061906
///|
19071907
/// Performs a bitwise OR operation between two unsigned 32-bit integers. For
@@ -1922,7 +1922,7 @@ pub fn UInt::land(self : UInt, other : UInt) -> UInt = "%u32.bitand"
19221922
/// let b = 0x0F0FU // Binary: 0000_1111_0000_1111
19231923
/// inspect(a | b, content="65535") // Binary: 1111_1111_1111_1111
19241924
/// ```
1925-
pub fn UInt::lor(self : UInt, other : UInt) -> UInt = "%u32.bitor"
1925+
pub impl BitOr for UInt with lor(self : UInt, other : UInt) -> UInt = "%u32.bitor"
19261926

19271927
///|
19281928
/// Performs a bitwise XOR (exclusive OR) operation between two unsigned 32-bit
@@ -1943,7 +1943,7 @@ pub fn UInt::lor(self : UInt, other : UInt) -> UInt = "%u32.bitor"
19431943
/// let b = 0x0F0FU // Binary: 0000_1111_0000_1111
19441944
/// inspect(a ^ b, content="61455") // Binary: 1111_0000_0000_1111
19451945
/// ```
1946-
pub fn UInt::lxor(self : UInt, other : UInt) -> UInt = "%u32.bitxor"
1946+
pub impl BitXOr for UInt with lxor(self : UInt, other : UInt) -> UInt = "%u32.bitxor"
19471947

19481948
///|
19491949
/// Performs a bitwise NOT operation on an unsigned 32-bit integer. Flips all

builtin/pkg.generated.mbti

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -369,14 +369,11 @@ fn Int::is_non_pos(Int) -> Bool
369369
fn Int::is_pos(Int) -> Bool
370370
fn Int::is_surrogate(Int) -> Bool
371371
fn Int::is_trailing_surrogate(Int) -> Bool
372-
fn Int::land(Int, Int) -> Int
373372
fn Int::lnot(Int) -> Int
374-
fn Int::lor(Int, Int) -> Int
375373
#deprecated
376374
fn Int::lsl(Int, Int) -> Int
377375
#deprecated
378376
fn Int::lsr(Int, Int) -> Int
379-
fn Int::lxor(Int, Int) -> Int
380377
fn Int::max(Int, Int) -> Int
381378
fn Int::min(Int, Int) -> Int
382379
fn Int::next_power_of_two(Int) -> Int
@@ -439,14 +436,11 @@ fn Int64::upto(Int64, Int64, inclusive? : Bool) -> Iter[Int64]
439436

440437
fn UInt::clz(UInt) -> Int
441438
fn UInt::ctz(UInt) -> Int
442-
fn UInt::land(UInt, UInt) -> UInt
443439
fn UInt::lnot(UInt) -> UInt
444-
fn UInt::lor(UInt, UInt) -> UInt
445440
#deprecated
446441
fn UInt::lsl(UInt, Int) -> UInt
447442
#deprecated
448443
fn UInt::lsr(UInt, Int) -> UInt
449-
fn UInt::lxor(UInt, UInt) -> UInt
450444
fn UInt::op_neq(UInt, UInt) -> Bool
451445
fn UInt::popcnt(UInt) -> Int
452446
fn UInt::reinterpret_as_float(UInt) -> Float
@@ -607,21 +601,27 @@ pub(open) trait BitAnd {
607601
land(Self, Self) -> Self
608602
}
609603
impl BitAnd for Byte
604+
impl BitAnd for Int
610605
impl BitAnd for Int64
606+
impl BitAnd for UInt
611607
impl BitAnd for UInt64
612608

613609
pub(open) trait BitOr {
614610
lor(Self, Self) -> Self
615611
}
616612
impl BitOr for Byte
613+
impl BitOr for Int
617614
impl BitOr for Int64
615+
impl BitOr for UInt
618616
impl BitOr for UInt64
619617

620618
pub(open) trait BitXOr {
621619
lxor(Self, Self) -> Self
622620
}
623621
impl BitXOr for Byte
622+
impl BitXOr for Int
624623
impl BitXOr for Int64
624+
impl BitXOr for UInt
625625
impl BitXOr for UInt64
626626

627627
pub(open) trait Compare : Eq {

bytes/pkg.generated.mbti

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,7 @@ fn default() -> Bytes
77
// Errors
88

99
// Types and methods
10-
type View
11-
#alias(op_get)
12-
fn View::at(Self, Int) -> Byte
13-
fn View::data(Self) -> Bytes
14-
fn View::find(Self, Self) -> Int?
15-
fn View::get(Self, Int) -> Byte?
16-
fn View::iter(Self) -> Iter[Byte]
17-
fn View::length(Self) -> Int
18-
fn View::rev_find(Self, Self) -> Int?
19-
fn View::start_offset(Self) -> Int
20-
#alias(op_as_view)
21-
fn View::sub(Self, start? : Int, end? : Int) -> Self
22-
fn View::to_bytes(Self) -> Bytes
23-
fn View::to_double_be(Self) -> Double
24-
fn View::to_double_le(Self) -> Double
25-
fn View::to_float_be(Self) -> Float
26-
fn View::to_float_le(Self) -> Float
27-
fn View::to_int64_be(Self) -> Int64
28-
fn View::to_int64_le(Self) -> Int64
29-
fn View::to_int_be(Self) -> Int
30-
fn View::to_int_le(Self) -> Int
31-
fn View::to_uint64_be(Self) -> UInt64
32-
fn View::to_uint64_le(Self) -> UInt64
33-
fn View::to_uint_be(Self) -> UInt
34-
fn View::to_uint_le(Self) -> UInt
35-
fn View::unsafe_extract_bit(Self, Int, Int) -> UInt
36-
fn View::unsafe_extract_byte(Self, Int, Int) -> UInt
37-
fn View::unsafe_extract_bytesview(Self, Int, Int) -> Self
38-
fn View::unsafe_extract_uint64_be(Self, Int, Int) -> UInt64
39-
fn View::unsafe_extract_uint64_le(Self, Int, Int) -> UInt64
40-
fn View::unsafe_extract_uint_be(Self, Int, Int) -> UInt
41-
fn View::unsafe_extract_uint_le(Self, Int, Int) -> UInt
42-
fn View::unsafe_get(Self, Int) -> Byte
43-
impl Compare for View
44-
impl Eq for View
45-
impl Hash for View
46-
impl Show for View
47-
48-
fn Bytes::find(Bytes, View) -> Int?
10+
fn Bytes::find(Bytes, BytesView) -> Int?
4911
#as_free_fn
5012
fn Bytes::from_array(Array[Byte]) -> Bytes
5113
#as_free_fn
@@ -57,14 +19,14 @@ fn Bytes::iter(Bytes) -> Iter[Byte]
5719
fn Bytes::iter2(Bytes) -> Iter2[Int, Byte]
5820
#as_free_fn
5921
fn Bytes::of(FixedArray[Byte]) -> Bytes
60-
fn Bytes::rev_find(Bytes, View) -> Int?
22+
fn Bytes::rev_find(Bytes, BytesView) -> Int?
6123
#alias(op_as_view)
62-
fn Bytes::sub(Bytes, start? : Int, end? : Int) -> View
24+
fn Bytes::sub(Bytes, start? : Int, end? : Int) -> BytesView
6325
fn Bytes::to_array(Bytes) -> Array[Byte]
6426
fn Bytes::to_fixedarray(Bytes, len? : Int) -> FixedArray[Byte]
6527
fn Bytes::unsafe_extract_bit(Bytes, Int, Int) -> UInt
6628
fn Bytes::unsafe_extract_byte(Bytes, Int, Int) -> UInt
67-
fn Bytes::unsafe_extract_bytesview(Bytes, Int, Int) -> View
29+
fn Bytes::unsafe_extract_bytesview(Bytes, Int, Int) -> BytesView
6830
fn Bytes::unsafe_extract_uint64_be(Bytes, Int, Int) -> UInt64
6931
fn Bytes::unsafe_extract_uint64_le(Bytes, Int, Int) -> UInt64
7032
fn Bytes::unsafe_extract_uint_be(Bytes, Int, Int) -> UInt
@@ -73,7 +35,45 @@ impl Add for Bytes
7335
impl Default for Bytes
7436
impl Hash for Bytes
7537

38+
#alias(op_get)
39+
fn BytesView::at(Self, Int) -> Byte
40+
fn BytesView::data(Self) -> Bytes
41+
fn BytesView::find(Self, Self) -> Int?
42+
fn BytesView::get(Self, Int) -> Byte?
43+
fn BytesView::iter(Self) -> Iter[Byte]
44+
fn BytesView::length(Self) -> Int
45+
fn BytesView::rev_find(Self, Self) -> Int?
46+
fn BytesView::start_offset(Self) -> Int
47+
#alias(op_as_view)
48+
fn BytesView::sub(Self, start? : Int, end? : Int) -> Self
49+
fn BytesView::to_bytes(Self) -> Bytes
50+
fn BytesView::to_double_be(Self) -> Double
51+
fn BytesView::to_double_le(Self) -> Double
52+
fn BytesView::to_float_be(Self) -> Float
53+
fn BytesView::to_float_le(Self) -> Float
54+
fn BytesView::to_int64_be(Self) -> Int64
55+
fn BytesView::to_int64_le(Self) -> Int64
56+
fn BytesView::to_int_be(Self) -> Int
57+
fn BytesView::to_int_le(Self) -> Int
58+
fn BytesView::to_uint64_be(Self) -> UInt64
59+
fn BytesView::to_uint64_le(Self) -> UInt64
60+
fn BytesView::to_uint_be(Self) -> UInt
61+
fn BytesView::to_uint_le(Self) -> UInt
62+
fn BytesView::unsafe_extract_bit(Self, Int, Int) -> UInt
63+
fn BytesView::unsafe_extract_byte(Self, Int, Int) -> UInt
64+
fn BytesView::unsafe_extract_bytesview(Self, Int, Int) -> Self
65+
fn BytesView::unsafe_extract_uint64_be(Self, Int, Int) -> UInt64
66+
fn BytesView::unsafe_extract_uint64_le(Self, Int, Int) -> UInt64
67+
fn BytesView::unsafe_extract_uint_be(Self, Int, Int) -> UInt
68+
fn BytesView::unsafe_extract_uint_le(Self, Int, Int) -> UInt
69+
fn BytesView::unsafe_get(Self, Int) -> Byte
70+
impl Compare for BytesView
71+
impl Eq for BytesView
72+
impl Hash for BytesView
73+
impl Show for BytesView
74+
7675
// Type aliases
76+
pub typealias BytesView as View
7777

7878
// Traits
7979

bytes/view.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
/// assert_eq(bv[2], b'\x03')
2727
/// ```
2828
#builtin.valtype
29-
type View
29+
pub typealias BytesView as View
3030
3131
///|
3232
fn View::bytes(self : View) -> Bytes = "%bytesview.bytes"

deque/pkg.generated.mbti

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package "moonbitlang/core/deque"
33

44
import(
55
"moonbitlang/core/json"
6-
"moonbitlang/core/string"
76
)
87

98
// Values
@@ -39,7 +38,7 @@ fn[A] Deque::insert(Self[A], Int, A) -> Unit
3938
fn[A] Deque::is_empty(Self[A]) -> Bool
4039
fn[A] Deque::iter(Self[A]) -> Iter[A]
4140
fn[A] Deque::iter2(Self[A]) -> Iter2[Int, A]
42-
fn Deque::join(Self[String], @string.View) -> String
41+
fn Deque::join(Self[String], StringView) -> String
4342
fn[A] Deque::length(Self[A]) -> Int
4443
fn[A, U] Deque::map(Self[A], (A) -> U) -> Self[U]
4544
fn[A, U] Deque::mapi(Self[A], (Int, A) -> U) -> Self[U]

encoding/utf8/pkg.generated.mbti

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,15 @@
11
// Generated using `moon info`, DON'T EDIT IT
22
package "moonbitlang/core/encoding/utf8"
33

4-
import(
5-
"moonbitlang/core/bytes"
6-
"moonbitlang/core/string"
7-
)
8-
94
// Values
10-
fn decode(@bytes.View, ignore_bom? : Bool) -> String raise Malformed
5+
fn decode(BytesView, ignore_bom? : Bool) -> String raise Malformed
116

12-
fn decode_lossy(@bytes.View, ignore_bom? : Bool) -> String
7+
fn decode_lossy(BytesView, ignore_bom? : Bool) -> String
138

14-
fn encode(@string.View, bom? : Bool) -> Bytes
9+
fn encode(StringView, bom? : Bool) -> Bytes
1510

1611
// Errors
17-
pub suberror Malformed @bytes.View
12+
pub suberror Malformed BytesView
1813

1914
// Types and methods
2015

0 commit comments

Comments
 (0)