-
Notifications
You must be signed in to change notification settings - Fork 464
/
Copy pathUncurriedAlways.res
67 lines (44 loc) · 1.33 KB
/
UncurriedAlways.res
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
@@uncurried
let foo = (x, y) => x + y
let z = foo(. 3, 4)
let bar = (. x, y) => x + y
let b = bar(3, 4)
let w = 3->foo(4)
let a = 3->foo(. 4)
Js.log(a) // Test automatic uncurried application
let _ = Js.Array2.map([1], (. x) => x + 1)
let ptl = @res.partial foo(10) // force partial application
let foo2 = (x, y) => x + y
let bar2: _ => _ = foo2(_, 3)
let foo3 = (x, y, z) => x + y + z
let bar3: _ => _ = foo3(_, 3, 4)
type cmp = Jsx.component<int>
let q: cmp = _ => Jsx.null // Check that subtyping works past type definitions
@inline
let inl = () => ()
@inline
let inl2 = (x,y) => x+y
module AllLabels = {
let foo = (~x, ~y, ~z) => (x, y, z)
let ptl = foo(~y="y", ...)
let a1 = ptl(~x="x", ~z="z")
Js.log2("a1:", a1)
}
module OptAtEnd = {
let foo = (~x, ~y, ~z, ~d="d=0") => (x, y, z, d)
let ptl = foo(~y="y", ...)
let b1 = ptl(~x="x", ~z="z")
Js.log2("b1:", b1)
let b2 = ptl(~x="x", ~z="z", ~d="d<-100")
Js.log2("b2:", b2)
}
module OptMixed = {
let foo = (~d1="d1=0", ~x, ~d2="d2=0", ~y, ~d3="d3=0", ~z, ~d4="d4=0", ~w, ~d5="d5=0") => (d1, x, d2, y, d3, z, d4, w, d5)
let ptl = foo(~y="y", ~w="w", ...)
let c1 = ptl(~x="x", ~z="z")
Js.log2("c1:", c1)
let c2 = ptl(~x="x", ~z="z", ~d1="d1<-100")
Js.log2("c2:", c2)
let c3 = ptl(~x="x", ~z="z", ~d2="d2<-200", ~d4="d4<-400")
Js.log2("c3:", c3)
}