Skip to content

Commit 2a4cc08

Browse files
authored
Merge branch 'main' into Feat/@ArrayView-blit_to()
2 parents 1890ecb + 93ddf3f commit 2a4cc08

File tree

108 files changed

+589
-1630
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+589
-1630
lines changed

.github/workflows/check.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@ jobs:
8282
run: |
8383
moon test --target native --release
8484
85-
- name: moon test --doc
86-
run: |
87-
moon test --doc
88-
8985
- name: moon bundle
9086
run: moon bundle --all
9187

@@ -227,10 +223,6 @@ jobs:
227223
env:
228224
MOONC_INTERNAL_PARAMS: allocator = tlsf-mbt |
229225

230-
- name: moon test --doc
231-
run: |
232-
moon test --doc
233-
234226
- name: moon check
235227
run: moon check
236228

array/array.mbti

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,9 @@ import(
77
)
88

99
// Values
10-
fn[T] copy(Array[T]) -> Array[T]
11-
12-
fn[A, B] filter_map(Array[A], (A) -> B? raise?) -> Array[B] raise?
13-
14-
fn join(Array[String], @string.StringView) -> String
15-
16-
fn[A] last(Array[A]) -> A?
17-
1810
#deprecated
1911
fn[T] push_iter(Array[T], Iter[T]) -> Unit
2012

21-
fn[T] shuffle(Array[T], rand~ : (Int) -> Int) -> Array[T]
22-
23-
fn[T] shuffle_in_place(Array[T], rand~ : (Int) -> Int) -> Unit
24-
25-
fn[T : Compare] sort(Array[T]) -> Unit
26-
27-
fn[T] sort_by(Array[T], (T, T) -> Int) -> Unit
28-
29-
fn[T, K : Compare] sort_by_key(Array[T], (T) -> K) -> Unit
30-
31-
fn[T1, T2] unzip(Array[(T1, T2)]) -> (Array[T1], Array[T2])
32-
33-
fn[A, B] zip(Array[A], Array[B]) -> Array[(A, B)]
34-
35-
fn[A, B] zip_to_iter2(Array[A], Array[B]) -> Iter2[A, B]
36-
3713
fn[A, B, C] zip_with(Array[A], Array[B], (A, B) -> C raise?) -> Array[C] raise?
3814

3915
// Types and methods
@@ -118,7 +94,7 @@ impl[X : Show] Show for ArrayView[X]
11894
impl[A : @quickcheck.Arbitrary] @quickcheck.Arbitrary for ArrayView[A]
11995

12096
// Type aliases
121-
pub typealias View[T] = ArrayView[T]
97+
pub typealias ArrayView as View
12298

12399
// Traits
124100

array/array_test.mbt

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -401,15 +401,15 @@ test "flatten" {
401401

402402
///|
403403
test "fold" {
404-
let sum = [1, 2, 3, 4, 5].fold(init=0, fn { sum, elem => sum + elem })
404+
let sum = [1, 2, 3, 4, 5].fold(init=0, (sum, elem) => sum + elem)
405405
assert_eq(sum, 15)
406406
}
407407

408408
///|
409409
test "rev_fold" {
410-
let sum = [1, 2, 3, 4, 5].rev_fold(init=0, fn { sum, elem => sum + elem })
410+
let sum = [1, 2, 3, 4, 5].rev_fold(init=0, (sum, elem) => sum + elem)
411411
assert_eq(sum, 15)
412-
let op = fn { sum, elem => sum - elem }
412+
let op = (sum, elem) => sum - elem
413413
let data = [1, 2, 3, 4, 5]
414414
let ss0 = data.rev_fold(init=0, op)
415415
let ss1 = data.rev().fold(init=0, op)
@@ -418,19 +418,15 @@ test "rev_fold" {
418418

419419
///|
420420
test "foldi" {
421-
let sum = [1, 2, 3, 4, 5].foldi(init=0, fn {
422-
index, sum, _elem => sum + index
423-
})
421+
let sum = [1, 2, 3, 4, 5].foldi(init=0, (index, sum, _elem) => sum + index)
424422
assert_eq(sum, 10)
425423
}
426424

427425
///|
428426
test "rev_foldi" {
429-
let sum = [1, 2, 3, 4, 5].rev_foldi(init=0, fn {
430-
index, sum, _elem => sum + index
431-
})
427+
let sum = [1, 2, 3, 4, 5].rev_foldi(init=0, (index, sum, _elem) => sum + index)
432428
assert_eq(sum, 10)
433-
let op = fn { index, sum, elem => index - sum - elem }
429+
let op = (index, sum, elem) => index - sum - elem
434430
let data = [1, 2, 3, 4, 5, 10]
435431
let v0 = data.rev_foldi(init=0, op)
436432
let v1 = data.rev().foldi(init=0, op)
@@ -514,13 +510,10 @@ test "shrink_to_fit_2" {
514510
///|
515511
test "iter" {
516512
let buf = StringBuilder::new(size_hint=5)
517-
[1, 2, 3, 4, 5].iter().each(fn { x => buf.write_string(x.to_string()) })
513+
[1, 2, 3, 4, 5].iter().each(x => buf.write_string(x.to_string()))
518514
inspect(buf, content="12345")
519515
buf.reset()
520-
[1, 2, 3, 4, 5]
521-
.iter()
522-
.take(2)
523-
.each(fn { x => buf.write_string(x.to_string()) })
516+
[1, 2, 3, 4, 5].iter().take(2).each(x => buf.write_string(x.to_string()))
524517
inspect(buf, content="12")
525518
}
526519

array/fixedarray.mbt

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,12 @@ pub fn[T] FixedArray::makei(
341341
342342
///|
343343
test "fixedarray_new_with_index" {
344-
let empty = FixedArray::makei(0, fn { i => i })
344+
let empty = FixedArray::makei(0, i => i)
345345
assert_eq(empty.length(), 0)
346-
let simple_arr = FixedArray::makei(1, fn { i => i })
346+
let simple_arr = FixedArray::makei(1, i => i)
347347
assert_eq(simple_arr.length(), 1)
348348
assert_eq(simple_arr[0], 0)
349-
let arr = FixedArray::makei(2, fn { i => i })
349+
let arr = FixedArray::makei(2, i => i)
350350
assert_eq(arr.length(), 2)
351351
assert_eq(arr[0], 0)
352352
assert_eq(arr[1], 1)
@@ -385,7 +385,7 @@ test "from_array" {
385385
///
386386
/// # Example
387387
/// ```mbt
388-
/// let sum = [1, 2, 3, 4, 5].fold(init=0, fn { sum, elem => sum + elem })
388+
/// let sum = [1, 2, 3, 4, 5].fold(init=0, (sum, elem) => sum + elem)
389389
/// assert_eq(sum, 15)
390390
/// ```
391391
pub fn[A, B] FixedArray::fold(
@@ -402,13 +402,12 @@ pub fn[A, B] FixedArray::fold(
402402
403403
///|
404404
test "fold" {
405-
let sum = ([] : FixedArray[_]).fold(init=1, fn { sum, elem => sum + elem })
405+
let sum = ([] : FixedArray[_]).fold(init=1, (sum, elem) => sum + elem)
406406
assert_eq(sum, 1)
407-
let sum = ([1] : FixedArray[_]).fold(init=2, fn { sum, elem => sum + elem })
407+
let sum = ([1] : FixedArray[_]).fold(init=2, (sum, elem) => sum + elem)
408408
assert_eq(sum, 3)
409-
let sum = ([1, 2, 3, 4, 5] : FixedArray[_]).fold(init=0, fn {
410-
sum, elem => sum + elem
411-
})
409+
let sum = ([1, 2, 3, 4, 5] : FixedArray[_]).fold(init=0, (sum, elem) => sum +
410+
elem)
412411
assert_eq(sum, 15)
413412
}
414413
@@ -417,7 +416,7 @@ test "fold" {
417416
///
418417
/// # Example
419418
/// ```mbt
420-
/// let sum = [1, 2, 3, 4, 5].rev_fold(init=0, fn { sum, elem => sum + elem })
419+
/// let sum = [1, 2, 3, 4, 5].rev_fold(init=0, (sum, elem) => sum + elem)
421420
/// assert_eq(sum, 15)
422421
/// ```
423422
pub fn[A, B] FixedArray::rev_fold(
@@ -434,15 +433,12 @@ pub fn[A, B] FixedArray::rev_fold(
434433
435434
///|
436435
test "rev_fold" {
437-
let sum = ([] : FixedArray[_]).rev_fold(init=1, fn { sum, elem => sum + elem })
436+
let sum = ([] : FixedArray[_]).rev_fold(init=1, (sum, elem) => sum + elem)
438437
assert_eq(sum, 1)
439-
let sum = ([1] : FixedArray[_]).rev_fold(init=2, fn {
440-
sum, elem => sum + elem
441-
})
438+
let sum = ([1] : FixedArray[_]).rev_fold(init=2, (sum, elem) => sum + elem)
442439
assert_eq(sum, 3)
443-
let sum = ([1, 2, 3, 4, 5] : FixedArray[_]).rev_fold(init=0, fn {
444-
sum, elem => sum + elem
445-
})
440+
let sum = ([1, 2, 3, 4, 5] : FixedArray[_]).rev_fold(init=0, (sum, elem) => sum +
441+
elem)
446442
assert_eq(sum, 15)
447443
}
448444
@@ -451,7 +447,7 @@ test "rev_fold" {
451447
///
452448
/// # Example
453449
/// ```mbt
454-
/// let sum = [1, 2, 3, 4, 5].foldi(init=0, fn { index, sum, _elem => sum + index })
450+
/// let sum = [1, 2, 3, 4, 5].foldi(init=0, (index, sum, _elem) => sum + index)
455451
/// assert_eq(sum, 10)
456452
/// ```
457453
pub fn[A, B] FixedArray::foldi(
@@ -468,7 +464,7 @@ pub fn[A, B] FixedArray::foldi(
468464
469465
///|
470466
test "fold_lefti" {
471-
let f = fn { index, sum, elem => index + sum + elem }
467+
let f = (index, sum, elem) => index + sum + elem
472468
{
473469
let sum = ([] : FixedArray[_]).foldi(init=1, f)
474470
assert_eq(sum, 1)
@@ -486,7 +482,7 @@ test "fold_lefti" {
486482
///
487483
/// # Example
488484
/// ```mbt
489-
/// let sum = [1, 2, 3, 4, 5].rev_foldi(init=0, fn { index, sum, _elem => sum + index })
485+
/// let sum = [1, 2, 3, 4, 5].rev_foldi(init=0, (index, sum, _elem) => sum + index)
490486
/// assert_eq(sum, 10)
491487
/// ```
492488
pub fn[A, B] FixedArray::rev_foldi(
@@ -504,7 +500,7 @@ pub fn[A, B] FixedArray::rev_foldi(
504500
505501
///|
506502
test "rev_foldi" {
507-
let f = fn { index, sum, elem => index + sum + elem }
503+
let f = (index, sum, elem) => index + sum + elem
508504
{
509505
let sum = ([] : FixedArray[_]).rev_foldi(init=1, f)
510506
assert_eq(sum, 1)

array/fixedarray_sort.mbt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -377,14 +377,13 @@ fn[T : Compare] fixed_choose_pivot(arr : FixedArraySlice[T]) -> (Int, Bool) {
377377
if len >= 8 {
378378
let a = len / 4 * 1
379379
let c = len / 4 * 3
380-
fn sort_2(a : Int, b : Int) {
380+
letrec sort_2 = fn(a : Int, b : Int) {
381381
if arr[a] > arr[b] {
382382
arr.swap(a, b)
383383
swaps += 1
384384
}
385385
}
386-
387-
fn sort_3(a : Int, b : Int, c : Int) {
386+
and sort_3 = fn(a : Int, b : Int, c : Int) {
388387
sort_2(a, b)
389388
sort_2(b, c)
390389
sort_2(a, b)
@@ -533,7 +532,7 @@ pub fn[T : Compare] FixedArray::is_sorted(arr : FixedArray[T]) -> Bool {
533532
///|
534533
test "stable_sort_complex" {
535534
let run_lens = [86, 64, 21, 20, 22]
536-
let total_len = run_lens.fold(init=0, fn { acc, x => acc + x })
535+
let total_len = run_lens.fold(init=0, (acc, x) => acc + x)
537536
let arr = FixedArray::make(total_len, 0)
538537
let mut index = 0
539538
for i = 0, len = run_lens.length(); i < len; i = i + 1 {

array/fixedarray_sort_by.mbt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,14 +287,13 @@ fn[T] fixed_choose_pivot_by(
287287
if len >= 8 {
288288
let a = len / 4 * 1
289289
let c = len / 4 * 3
290-
fn sort_2(a : Int, b : Int) {
290+
letrec sort_2 = fn(a : Int, b : Int) {
291291
if cmp(arr[a], arr[b]) > 0 {
292292
arr.swap(a, b)
293293
swaps += 1
294294
}
295295
}
296-
297-
fn sort_3(a : Int, b : Int, c : Int) {
296+
and sort_3 = fn(a : Int, b : Int, c : Int) {
298297
sort_2(a, b)
299298
sort_2(b, c)
300299
sort_2(a, b)

array/sort.mbt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,14 +170,13 @@ fn[T : Compare] choose_pivot(arr : ArrayView[T]) -> (Int, Bool) {
170170
if len >= 8 {
171171
let a = len / 4 * 1
172172
let c = len / 4 * 3
173-
fn sort_2(a : Int, b : Int) {
173+
letrec sort_2 = fn(a : Int, b : Int) {
174174
if arr[a] > arr[b] {
175175
arr.swap(a, b)
176176
swaps += 1
177177
}
178178
}
179-
180-
fn sort_3(a : Int, b : Int, c : Int) {
179+
and sort_3 = fn(a : Int, b : Int, c : Int) {
181180
sort_2(a, b)
182181
sort_2(b, c)
183182
sort_2(a, b)

array/sort_by.mbt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,13 @@ fn[T] choose_pivot_by(arr : ArrayView[T], cmp : (T, T) -> Int) -> (Int, Bool) {
192192
if len >= 8 {
193193
let a = len / 4 * 1
194194
let c = len / 4 * 3
195-
fn sort_2(a : Int, b : Int) {
195+
letrec sort_2 = fn(a : Int, b : Int) {
196196
if cmp(arr[a], arr[b]) > 0 {
197197
arr.swap(a, b)
198198
swaps += 1
199199
}
200200
}
201-
202-
fn sort_3(a : Int, b : Int, c : Int) {
201+
and sort_3 = fn(a : Int, b : Int, c : Int) {
203202
sort_2(a, b)
204203
sort_2(b, c)
205204
sort_2(a, b)

array/view.mbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ pub fn[A] View::iter2(self : View[A]) -> Iter2[Int, A] {
219219
///
220220
/// # Example
221221
/// ```mbt
222-
/// let sum = [1, 2, 3, 4, 5][:].fold(init=0, fn { sum, elem => sum + elem })
222+
/// let sum = [1, 2, 3, 4, 5][:].fold(init=0, (sum, elem) => sum + elem)
223223
/// assert_eq(sum, 15)
224224
/// ```
225225
pub fn[A, B] View::fold(
@@ -239,7 +239,7 @@ pub fn[A, B] View::fold(
239239
///
240240
/// # Example
241241
/// ```mbt
242-
/// let sum = [1, 2, 3, 4, 5][:].rev_fold(init=0, fn { sum, elem => sum + elem })
242+
/// let sum = [1, 2, 3, 4, 5][:].rev_fold(init=0, (sum, elem) => sum + elem)
243243
/// assert_eq(sum, 15)
244244
/// ```
245245
pub fn[A, B] View::rev_fold(
@@ -259,7 +259,7 @@ pub fn[A, B] View::rev_fold(
259259
///
260260
/// # Example
261261
/// ```mbt
262-
/// let sum = [1, 2, 3, 4, 5][:].foldi(init=0, fn { index, sum, _elem => sum + index })
262+
/// let sum = [1, 2, 3, 4, 5][:].foldi(init=0, (index, sum, _elem) => sum + index)
263263
/// assert_eq(sum, 10)
264264
/// ```
265265
pub fn[A, B] View::foldi(

bench/bench.mbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ pub fn single_bench(
7777
}
7878

7979
// NOTE: use a type parameter `Any` to avoid exposing `trait OpaqueValue` to users
80+
8081
///|
8182
/// Keep a value to prevent the optimizer from removing
8283
/// the calculation that produces it.

0 commit comments

Comments
 (0)