forked from rescript-lang/rescript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinary.res
More file actions
411 lines (341 loc) · 10.4 KB
/
binary.res
File metadata and controls
411 lines (341 loc) · 10.4 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
let x = a + b
let x = @attr (a + b)
let x = @attr (@attr a + @attr b)
let x = a && b + c
let x = (a && b) + c
let x = a && b || c
let x = (a && b) + (c && d)
while (continuePrefix.contents && aPrefixLen.contents && bPrefixLen.contents && foobarLen.contents) {
()
}
// uncurried attribute shouldn't result in parens
while (
rbt.compare(. Js.Array2.unsafe_get(old, oldIter.contents), node.value) < 0
) {
()
}
// unary expr as child of binary expr doesn't need parens
let x = !filePath.includes(allMlSuffixesCategory) &&
!filePath.endsWith(allScriptDirectoriesCategory)
let name = names[0] ++ names[1]
let name = user["firstName"] ++ user["lastName"]
let x = foo ++ bar
let x = foo != bar
let x = foo !== bar
let x = foo ++ bar
let x = 1 + 1
let x = (a => a + 1) + (b => b + 2)
let x = -1 + -1
let x = switch z { | Red => 1 } |> switch y { | Blue => 2 }
let x = try z catch { | Exit => 1 } |> try y catch { | Blue => 2 }
let x = if true { 1 } else { 2 } + if false { 2 } else { 3 }
let x = for i in 0 to 10 { () } |> for i in 0 to 10 { () }
let x = (a, b) + (b, c)
let x = Vec3(a, b, c) + Vec4(a, b, c, d)
let x = {x: 1, y: 2} + {x: 2, y :3}
let x = user.firstName ++ user.lastName
let x = x.left = value |> x.right = value
let x = (x.left = value) |> x.right = value
let x = (x.left = value) |> (x.right = value)
let () = (x.left = value) |> logMutation
let () = x.left = value |> logMutation
let () = x.left = (value |> process) |> x.right = value |> process
let () = (x: int) |> (print_int: int => unit)
// math
x + y / z
x / y + z
x % y * z
x ^ y + z
100 * x / total
2 / 3 * 10 / 2 + 2
let rotateX = ((range / rect.height) * refY - range / 2) * getXMultiplication(rect.width)
let rotateY = ((range / rect.width) * refX - range / 2) * getYMultiplication(rect.width)
let x = longIdentifier + longIdentifier + longIdentifier;
let x = longIdentifier + longIdentifier + longIdentifier + longIdentifier - longIdentifier + longIdentifier;
let x = longIdentifier + longIdentifier * longIdentifier + longIdentifier - longIdentifier + longIdentifier;
let x = longIdentifier + longIdentifier * longIdentifier * longIdentifier / longIdentifier + longIdentifier;
let x = longIdentifier && longIdentifier && longIdentifier && longIdentifier && longIdentifier && longIdentifier;
let x = longIdentifier && longIdentifier || longIdentifier && longIdentifier || longIdentifier && longIdentifier;
// exponentiation is right associative
let x = 2. ** 3. ** 2.
let x = (2. ** 3.) ** 2.
let x = 2. ** (3. ** 2.)
if (
successorParent.color === Black &&
(sibling === None ||
(siblingNN.color === Black &&
siblingNN.left === None ||
(siblingNN.left->castNotOption).color === Black &&
(siblingNN.right === None ||
(siblingNN.right->castNotOption).color === Black)))
) {
if sibling !== None {
siblingNN.color = Red
}
successorRef.contents = successorParent
}
let truth = longEqualityExpression.someRecordField ==
wowThisDoesHaveToBePrettyLong.someRecordField &&
longEqualityExpression.someRecordField ==
wowThisDoesHaveToBePrettyLong.someRecordField
while (
continuePrefix.contents &&
aPrefixLen.contents <= aLen &&
bPrefixLen.contents <= bLen
) {
let nextNonwhiteA = nextNonWhiteChar(aStr, 1, aPrefixLen.contents - 1)
let nextNonwhiteB = nextNonWhiteChar(bStr, 1, bPrefixLen.contents - 1)
()
}
let () = {
let () = sideEffect()
if (
(isLeft(successor) && sibling.right === None) ||
((sibling.right->castNotOption).color === Black &&
sibling.left !== None &&
(sibling.left->castNotOption).color === Red)
) {
sibling.color = Red
sibling.left->castNotOption.color = Black
rotateRight(rbt, sibling)
}
if (
sibling !== None && (sibling->castNotOption).color === Black
) {
let sibling = sibling->castNotOption
if (
isLeft(successor) &&
sibling.right === None ||
(sibling.right->castNotOption).color === Black &&
sibling.left !== None &&
(sibling.left->castNotOption).color === Red
) {
sibling.color = Red
sibling.left->castNotOption.color = Black
rotateRight(rbt, sibling)
} else if (
!isLeft(successor) &&
sibling.left === None ||
(sibling.left->castNotOption).color === Black &&
sibling.right !== None &&
(sibling.right->castNotOption).color === Red
) {
sibling.color = Red
sibling.right->castNotOption.color = Black
rotateLeft(rbt, sibling)
}
break.contents = true
} else {
let sibling = siblingOf(successor)
let sibling = sibling->castNotOption
sibling.color = successorParent.color
if isLeft(successor) {
sibling.right->castNotOption.color = Black
rotateRight(rbt, successorParent)
} else {
sibling.left->castNotOption.color = Black
rotateLeft(rbt, successorParent)
}
}
}
let x = a && (b || c)
let x = a && (b || c) && d
let x = a && b + c
let x = a && b + c && d
let x = a && @attr b && c
let x = @attr a && @attr b && @attr c
let x = a && @attr (b && c)
let x = a && @attr (b && c) && @attr (d && e)
let x = a && @attr (x |> f(g))
let x = a && @attr (x |> f(g)) && @attr (y |> f(h))
let x = a && a.b
let x = a && x.y && g.h
let x = a && true
let x = a && true && true
let x = a && {let a = true; let b = true; a || b}
let x = a && {let a = true; let b = true; a || b} && {let a = true; let b = true; a || b}
let x = a && x => x->Js.log
let x = a && (x => x->Js.log) && x => x->Js.log
let x = a && !b
let x = a && !b && !c
let x = a && f(b)
let x = a && f(b) && f(c)
let x = a && f(. b)
let x = a && f(. b) && f(. c)
let x = a && x |> f(g)
let x = a && x |> f(g) && y |> f(h)
let x = a && switch color {
| Blue => "blue"
| Red => "red"
}
let x = a && switch color {
| Blue => "blue"
| Red => "red"
} && switch color {
| Blue => "blue"
| Red => "red"
}
let x = a && try unsafe() catch {
| Error => ()
}
let x = a && try unsafe() catch {
| Error => ()
} && try unsafe() catch {
| Error => ()
}
let x = a && (a, b)
let x = a && (a, b) && (c, d)
let x = a && Foo(x, y)
let x = a && Foo(x, y) && Foo(x, y, z)
let x = a && {x: 1, y: 2}
let x = a && {x: 1, y: 2} && {x: 3, y: 3}
let x = a && b.c
let x = a && b.c && d.e
let x = a && row.id = 1
let x = a && (row.id = 1) && row2.id = 3
let x = a && [a, b]
let x = a && [a, b] && [c, d]
let x = a && if true { true } else { false }
let x = a && if true { true } else { false } && if false { false } else { true}
let x = a && {sideEffect(); do()}
let x = a && {sideEffect(); do()} && {sideEffect(); do()}
let x = a && while true { do() }
let x = a && while true { do() } && while true { do() }
let x = a && for i in 0 to 10 { true }
let x = a && for i in 0 to 10 { true } && for i in 0 to 10 { false }
let x = a && (truth: bool)
let x = a && (truth: bool) && (otherTruth: bool)
let x = a && {module L = Log; L.log()}
let x = a && {module L = Log; L.log()} && {module L = Log; L.log()}
let x = a && {exception Exit; raise(Exit)}
let x = a && {exception Exit; raise(Exit)} && {exception Exit; raise(Exit)}
let x = a && assert(false)
let x = a && assert(false) && assert(true)
let x = a && {open React; killPerform()}
let x = a && {open React; killPerform()} && {open Dom; regainPerform()}
let x = a && %raw("true")
let x = a && %raw("true") && %raw("false")
let x = a && module(Foo)
let x = a && module(Foo) && module(Bar)
let x = a && module(Foo: Bool)
let x = a && module(Foo: Bool) && module(Bar: Bool)
let x = a && truths[0]
let x = a && truths[0] && truths[1]
let () = node.left := value |> process |> node.right = value |> process
let () = (node.left := value |> process) |> node.right = value |> process
let x = (true ? 0 : 1) + (false ? 1 : 0)
let x = (true ? 0 : 1) + (false ? 1 : 0) + (false ? 1 : 0)
while (
oldIter.contents < oldLen &&
rbt.compare(.
Js.Array2.unsafe_get(old, oldIter.contents),
node.value,
)
) {
disappear(. Js.Array2.unsafe_get(old, oldIter.contents))
oldIter.contents = oldIter.contents + 1
}
while (
oldIter.contents < oldLen &&
rbt.compare(.
Js.Array2.unsafe_get(old, oldIter.contents),
node.value,
) < 0
) {
disappear(. Js.Array2.unsafe_get(old, oldIter.contents))
oldIter.contents = oldIter.contents + 1
}
let x =
oldIter.contents < oldLen &&
rbt.compare(Js.Array2.unsafe_get(old, oldIter.contents), node.value) < veryLongIdentifier;
// should be formatted on one line, i.e. NOT break
let fullCircle = 2. *. pi
a + b + c
a + b - c
a < b < c
a + (b + c)
a + (b + (c + d))
a + (b - (c - d))
a < (b < c)
a < (b < (c < d))
a || b || c
a || (b || c)
a || (b || (c || d))
a && b && c
a && (b && c)
a && (b && (c && d))
a && b || c
a && (b || c)
x->(y->z)
x->(y->(z->w))
x->(y &&(w && z))
(x->y)->z
(x |> y) |> z
x |> (y |> z)
x |> (y |> (z |> w))
let x = "z" ++ (a |> f) ++ "x"
let toString = functionArgs => {
functionArgs == []
? ""
: "<"
++ (functionArgs |> List.map(argToString) |> String.concat(","))
++ ">"
}
a |> Author.id != (author |> Author.id)
// should indent the switch
foo :=
switch bar.contents {
| _ => 1
}
<div> {possibleGradeValues |> List.filter(g =>
g < state.maxGrade
) |> List.map(possibleGradeValue =>
<option key={possibleGradeValue |> string_of_int} value={possibleGradeValue |> string_of_int}>
{possibleGradeValue |> string_of_int |> str}
</option>
) |> Array.of_list |> ReasonReact.array} </div>
let aggregateTotal = (forecast, ~audienceType) =>
Js.Nullable.toOption(forecast["audiences"])
->Option.flatMap(item =>
Js.Dict.get(item, audienceType)
)
->Option.map(item => {
pages: item["reach"]["pages"],
views: item["reach"]["views"],
sample: item["reach"]["sample"],
})
React.useEffect4(
() => {
switch (context.library, context.account) {
| (Some(library), Some(account)) =>
library.getBalance(. account)
->Promise.Js.catch(_ => {Promise.resolved(None)})
->Promise.get(newBalance => {
dispatch(
LoadAddress(
account,
newBalance->Belt.Option.flatMap(balance =>
Eth.make(balance.toString(.))
),
),
)
})
None
| _ => None
}
},
(context.library, context.account, context.chainId, dispatch),
)
@react.component
let make = (~keycap) =>
<Kbd keycap="Ctrl" /> +
<Kbd keycap="Shift" /> +
<Kbd keycap />
<Kbd keycap="Cmd" /> +
<Kbd keycap="Option" /> +
<Kbd keycap="Shift" /> +
<Kbd keycap />
// rescript-lang/syntax/issues/499
(@doesNotRaise [])->Belt.Array.getExn(0)
@doesNotRaise
[]->Belt.Array.getExn(0)