Skip to content

Commit b0a4d41

Browse files
committed
Add built-in tuple primitives to the prelude
1 parent d65804e commit b0a4d41

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

hkmc2/shared/src/test/mlscript/ucs/patterns/RestTuple.mls

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
:js
22
:ucs desugared
33

4-
fun tupleSlice(xs, i, j) = globalThis.Array.prototype.slice.call(xs, i, xs.length - j)
5-
fun tupleGet(xs, i) = globalThis.Array.prototype.at.call(xs, i)
4+
:import ../Prelude/Tuple.mls
5+
//│ Imported 2 member(s)
66

77
// Drop the first and last elements.
88
tupleSlice([1, 2, 3, 4], 1, -1)
@@ -23,7 +23,7 @@ fun stupid(xs) = if xs is
2323
//│ Desugared:
2424
//│ > if
2525
//│ > xs@59 is []>=0 and
26-
//│ > let $rest@60 = globalThis:block#1#666.tupleSlice‹member:tupleSlice›(xs@59#2, 0, 0)
26+
//│ > let $rest@60 = globalThis:import#Tuple#666.tupleSlice‹member:tupleSlice›(xs@59#2, 0, 0)
2727
//│ > let ys@61 = $rest@60#0
2828
//│ > else ys@61#666
2929
//│ > xs@59 is []=0 then "empty"
@@ -58,8 +58,8 @@ fun foo(xs) = if xs is
5858
//│ > if
5959
//│ > xs@71 is []>=2 and
6060
//│ > let $first0@74 = xs@71#2.0
61-
//│ > let $rest@73 = globalThis:block#1#666.tupleSlice‹member:tupleSlice›(xs@71#3, 1, 1)
62-
//│ > let $last0@72 = globalThis:block#1#666.tupleGet‹member:tupleGet›(xs@71#4, -1)
61+
//│ > let $rest@73 = globalThis:import#Tuple#666.tupleSlice‹member:tupleSlice›(xs@71#3, 1, 1)
62+
//│ > let $last0@72 = globalThis:import#Tuple#666.tupleGet‹member:tupleGet›(xs@71#4, -1)
6363
//│ > let x@75 = $first0@74#0
6464
//│ > let ys@76 = $rest@73#0
6565
//│ > let y@77 = $last0@72#0
@@ -108,8 +108,8 @@ fun nested_tuple_patterns(xs) = if xs is
108108
//│ > if
109109
//│ > xs@96 is []>=2 and
110110
//│ > let $first0@99 = xs@96#2.0
111-
//│ > let $rest@98 = globalThis:block#1#666.tupleSlice‹member:tupleSlice›(xs@96#3, 1, 1)
112-
//│ > let $last0@97 = globalThis:block#1#666.tupleGet‹member:tupleGet›(xs@96#4, -1)
111+
//│ > let $rest@98 = globalThis:import#Tuple#666.tupleSlice‹member:tupleSlice›(xs@96#3, 1, 1)
112+
//│ > let $last0@97 = globalThis:import#Tuple#666.tupleGet‹member:tupleGet›(xs@96#4, -1)
113113
//│ > let x@100 = $first0@99#0
114114
//│ > $rest@98 is []=2 and
115115
//│ > let $first0@102 = $rest@98#1.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fun tupleSlice(xs, i, j) = globalThis.Array.prototype.slice.call(xs, i, xs.length - j)
2+
fun tupleGet(xs, i) = globalThis.Array.prototype.at.call(xs, i)

0 commit comments

Comments
 (0)