forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathunary.res
70 lines (58 loc) · 1.09 KB
/
unary.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
68
69
70
let x = -a
let x = -.a
let x = !a
let isMale = !user["female"]
!(!a)
!(!(!a))
!(a |> f(b))
(-1)->add
-1->add
-(1->add)
!foo->print_bool
(!foo)->print_bool
!(foo->parseTruth)
node.left->peekMinNode
// same as the above
(node.left)->peekMinNode
// field access has higher precedence than unary -
let x = -a.bar
// same as above
let x = -(a.bar)
!(assert(x))
assert(!x)
!(@attr expr)
//!(arg => doStuffWith(arg))
let x = !(truth: bool)
let x = (!truth: bool)
let z = !%extension
// (!x.left) = value -> this does not parse, lhs of Pexp_setfield can't be a unary expression?
-[a, b, c]
!module(Foo: Bar)
!module(Foo)
let x = -apply(arg)
let x = -apply(. arg)
let x = -Foo(a, b, c)
let x = -{x:1, y: 2}
let x = -list{1, 2, 3}
let x = -(if true { 1 } else { 2 })
let x = -(for i in 0 to 10 { () })
let x = -(switch x {| Foo => 1})
let x = -(while i < 10 { i.contents = 20 })
let x = -(1, 2, 3)
let x = -{
let a = 1
let b = 2
a + b
}
let x = -{
sideEffect()
generateNumber()
}
-(true ? 0 : 1)
let () = {
getResult()
-10
}
let x = (!truths)[0]
(!streets)[0] = "foo-street"
!(arg => doStuffWith(arg))