-
Notifications
You must be signed in to change notification settings - Fork 484
Expand file tree
/
Copy pathPervasives.res
More file actions
371 lines (269 loc) · 11.7 KB
/
Copy pathPervasives.res
File metadata and controls
371 lines (269 loc) · 11.7 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
@deprecated("Do not use. This will be removed in v13")
external __unsafe_cast: 'a => 'b = "%identity"
/* Exceptions */
/**
Raises the given exception, terminating execution unless caught by a surrounding try/catch block.
## Examples
```rescript
exception MyException(string)
let result = try {
throw(MyException("Out of milk"))
} catch {
| MyException(message) => "Caught exception: " ++ message
}
result == "Caught exception: Out of milk"
```
*/
external throw: exn => 'a = "%raise"
external assert: bool => 'a = "%assert"
@deprecated({
reason: "`raise` has been renamed to `throw` to align with JavaScript vocabulary. Please use `throw` instead",
migrate: throw(),
})
external raise: exn => 'a = "%raise"
@deprecated("Use custom exception instead")
let failwith = s => throw(Failure(s))
@deprecated("Use custom exception instead")
let invalid_arg = s => throw(Invalid_argument(s))
@deprecated("Use custom exception instead") exception Exit
/* Composition operators */
@deprecated("This will be removed in v13")
external \"|>": ('a, 'a => 'b) => 'b = "%revapply"
@deprecated("This will be removed in v13")
external \"@@": ('a => 'b, 'a) => 'b = "%apply"
/* Debugging */
external __LOC__: string = "%loc_LOC"
external __FILE__: string = "%loc_FILE"
external __LINE__: int = "%loc_LINE"
external __MODULE__: string = "%loc_MODULE"
external __POS__: (string, int, int, int) = "%loc_POS"
external __LOC_OF__: 'a => (string, 'a) = "%loc_LOC"
external __LINE_OF__: 'a => (int, 'a) = "%loc_LINE"
external __POS_OF__: 'a => ((string, int, int, int), 'a) = "%loc_POS"
/* Unified operations */
external \"~+": 'a => 'a = "%plus"
external \"~-": 'a => 'a = "%neg"
external \"+": ('a, 'a) => 'a = "%add"
external \"-": ('a, 'a) => 'a = "%sub"
external \"*": ('a, 'a) => 'a = "%mul"
external \"/": ('a, 'a) => 'a = "%div"
external \"%": ('a, 'a) => 'a = "%mod"
external \"<<": ('a, 'a) => 'a = "%lsl"
external mod: ('a, 'a) => 'a = "%mod"
external \"**": ('a, 'a) => 'a = "%pow"
external \"~~~": 'a => 'a = "%bitnot"
external \"|||": ('a, 'a) => 'a = "%bitor"
external \"^^^": ('a, 'a) => 'a = "%bitxor"
external \"&&&": ('a, 'a) => 'a = "%bitand"
external \">>": ('a, 'a) => 'a = "%asr"
external \">>>": ('a, 'a) => 'a = "%lsr"
/* Comparisons */
/* Note: Later comparisons will be converted to unified operations too */
external \"==": ('a, 'a) => bool = "%equal"
external \"!=": ('a, 'a) => bool = "%notequal"
external \"<": ('a, 'a) => bool = "%lessthan"
external \">": ('a, 'a) => bool = "%greaterthan"
external \"<=": ('a, 'a) => bool = "%lessequal"
external \">=": ('a, 'a) => bool = "%greaterequal"
external compare: ('a, 'a) => int = "%compare"
external min: ('a, 'a) => 'a = "%min"
external max: ('a, 'a) => 'a = "%max"
external \"===": ('a, 'a) => bool = "%eq"
external \"!==": ('a, 'a) => bool = "%noteq"
/* Boolean operations */
external not: bool => bool = "%boolnot"
external \"&&": (bool, bool) => bool = "%sequand"
external \"||": (bool, bool) => bool = "%sequor"
/* Integer operations */
@deprecated("Use `x => x + 1` instead. This will be removed in v13")
external succ: int => int = "%succint"
@deprecated("Use `x => x - 1` instead. This will be removed in v13")
external pred: int => int = "%predint"
@deprecated("Use `Math.abs` instead. This will be removed in v13")
let abs = x =>
if x >= 0 {
x
} else {
-x
}
@deprecated("Use `Int.bitwiseAnd` instead. This will be removed in v13")
external land: (int, int) => int = "%andint"
@deprecated("Use `Int.bitwiseOr` instead. This will be removed in v13")
external lor: (int, int) => int = "%orint"
@deprecated("Use `Int.bitwiseXor` instead. This will be removed in v13")
external lxor: (int, int) => int = "%xorint"
@deprecated("Use `Int.bitwiseNot` instead. This will be removed in v13")
external lnot: int => int = "%bitnot_int"
@deprecated("Use `Int.shiftLeft` instead. This will be removed in v13")
external lsl: (int, int) => int = "%lslint"
@deprecated("Use `Int.shiftRightUnsigned` instead. This will be removed in v13")
external lsr: (int, int) => int = "%lsrint"
@deprecated("Use `Int.shiftRight` instead. This will be removed in v13")
external asr: (int, int) => int = "%asrint"
@deprecated("Use `Int.Constants.maxValue` instead. This will be removed in v13")
let max_int = lsr(-1, 1)
@deprecated("Use `Int.Constants.minValue` instead. This will be removed in v13")
let min_int =
max_int + 1
/* Floating-point operations */
external \"~-.": float => float = "%negfloat"
external \"~+.": float => float = "%identity"
external \"+.": (float, float) => float = "%addfloat"
external \"-.": (float, float) => float = "%subfloat"
external \"*.": (float, float) => float = "%mulfloat"
external \"/.": (float, float) => float = "%divfloat"
@deprecated("Use `Math.exp` instead. This will be removed in v13") @val @scope("Math")
external exp: float => float = "exp"
@deprecated("Use `Math.acos` instead. This will be removed in v13") @val @scope("Math")
external acos: float => float = "acos"
@deprecated("Use `Math.asin` instead. This will be removed in v13") @val @scope("Math")
external asin: float => float = "asin"
@deprecated("Use `Math.atan` instead. This will be removed in v13") @val @scope("Math")
external atan: float => float = "atan"
@deprecated("Use `Math.atan2` instead. This will be removed in v13") @val @scope("Math")
external atan2: (float, float) => float = "atan2"
@deprecated("Use `Math.cos` instead. This will be removed in v13") @val @scope("Math")
external cos: float => float = "cos"
@deprecated("Use `Math.cosh` instead. This will be removed in v13") @val @scope("Math")
external cosh: float => float = "cosh"
@deprecated("Use `Math.log` instead. This will be removed in v13") @val @scope("Math")
external log: float => float = "log"
@deprecated("Use `Math.log10` instead. This will be removed in v13") @val @scope("Math")
external log10: float => float = "log10"
@deprecated("Use `Math.log1p` instead. This will be removed in v13") @val @scope("Math")
external log1p: float => float = "log1p"
@deprecated("Use `Math.sin` instead. This will be removed in v13") @val @scope("Math")
external sin: float => float = "sin"
@deprecated("Use `Math.sinh` instead. This will be removed in v13") @val @scope("Math")
external sinh: float => float = "sinh"
@deprecated("Use `Math.sqrt` instead. This will be removed in v13") @val @scope("Math")
external sqrt: float => float = "sqrt"
@deprecated("Use `Math.tan` instead. This will be removed in v13") @val @scope("Math")
external tan: float => float = "tan"
@deprecated("Use `Math.tanh` instead. This will be removed in v13") @val @scope("Math")
external tanh: float => float = "tanh"
@deprecated("Use `Math.ceil` instead. This will be removed in v13") @val @scope("Math")
external ceil: float => float = "ceil"
@deprecated("Use `Math.floor` instead. This will be removed in v13") @val @scope("Math")
external floor: float => float = "floor"
@deprecated("Use `Math.abs` instead. This will be removed in v13") @val @scope("Math")
external abs_float: float => float = "abs"
@deprecated("Use `%` instead. This will be removed in v13")
external mod_float: (float, float) => float = "%modfloat"
@deprecated("Use `Int.toFloat` instead. This will be removed in v13")
external float: int => float = "%floatofint"
@deprecated("Use `Int.toFloat` instead. This will be removed in v13")
external float_of_int: int => float = "%floatofint"
@deprecated("Use `Float.toInt` instead. This will be removed in v13")
external truncate: float => int = "%intoffloat"
@deprecated("Use `Float.toInt` instead. This will be removed in v13")
external int_of_float: float => int = "%intoffloat"
@deprecated("Use `Float.positiveInfinity` instead. This will be removed in v13")
let infinity = 0x1p2047
@deprecated("Use `Float.negativeInfinity` instead. This will be removed in v13")
let neg_infinity = -0x1p2047
@deprecated("Use `Float.nan` instead. This will be removed in v13") @val @scope("Number")
external nan: float = "NaN"
@deprecated("Use `Float.Constants.maxValue` instead. This will be removed in v13")
let max_float = 1.79769313486231571e+308 /* 0x1.ffff_ffff_ffff_fp+1023 */
@deprecated("Use `Float.Constants.minValue` instead. This will be removed in v13")
let min_float = 2.22507385850720138e-308 /* 0x1p-1022 */
@deprecated("Use `Float.Constants.epsilon` instead. This will be removed in v13")
let epsilon_float = 2.22044604925031308e-16 /* 0x1p-52 */
@deprecated("Do not use. This will be removed in v13")
type fpclass =
| FP_normal
| FP_subnormal
| FP_zero
| FP_infinite
| FP_nan
@deprecated("Do not use. This will be removed in v13")
let classify_float = (x: float): fpclass =>
if (%raw(`isFinite`): _ => _)(x) {
if abs_float(x) >= /* 0x1p-1022 */ /* 2.22507385850720138e-308 */ min_float {
FP_normal
} else if x != 0. {
FP_subnormal
} else {
FP_zero
}
} else if (%raw(`isNaN`): _ => _)(x) {
FP_nan
} else {
FP_infinite
}
/* String and byte sequence operations -- more in modules String and Bytes */
external \"++": (string, string) => string = "%string_concat"
/* Character operations -- more in module Char */
@deprecated("Use type `string` and `String.charCodeAt` instead. This will be removed in v13")
external int_of_char: char => int = "%identity"
@deprecated("Use type `string` and `String.fromCharCode` instead. This will be removed in v13")
external unsafe_char_of_int: int => char = "%identity"
@deprecated("Use type `string` and `String.fromCharCode` instead. This will be removed in v13")
let char_of_int = n =>
if n < 0 || n > 255 {
invalid_arg("char_of_int")
} else {
unsafe_char_of_int(n)
}
/* Unit operations */
external ignore: 'a => unit = "%ignore"
/* Pair operations */
@deprecated("Use `Pair.first` instead. This will be removed in v13")
external fst: (('a, 'b)) => 'a = "%field0"
@deprecated("Use `Pair.second` instead. This will be removed in v13")
external snd: (('a, 'b)) => 'b = "%field1"
/* References */
type ref<'a> = {mutable contents: 'a}
external ref: 'a => ref<'a> = "%makeref"
external \":=": (ref<'a>, 'a) => unit = "%refset"
@deprecated("Do not use. This will be removed in v13")
external \"!": ref<'a> => 'a = "%refget"
@deprecated("Use `Int.Ref.increment` instead. This will be removed in v13")
external incr: ref<int> => unit = "%incr"
@deprecated("Use `Int.Ref.decrement` instead. This will be removed in v13")
external decr: ref<int> => unit = "%decr"
/* String conversion functions */
@deprecated("Use `Bool.toString` instead. This will be removed in v13")
let string_of_bool = b =>
if b {
"true"
} else {
"false"
}
@deprecated("Use `Bool.fromString` instead. This will be removed in v13")
let bool_of_string = param =>
switch param {
| "true" => true
| "false" => false
| _ => invalid_arg("bool_of_string")
}
@deprecated("Use `Bool.fromString` instead. This will be removed in v13")
let bool_of_string_opt = param =>
switch param {
| "true" => Some(true)
| "false" => Some(false)
| _ => None
}
@deprecated("Use `Int.toString` instead. This will be removed in v13")
external string_of_int: int => string = "String"
@deprecated("Use `Int.fromString` instead. This will be removed in v13") @scope("Number")
external int_of_string: string => int = "parseInt"
@deprecated("Use `Int.fromString` instead. This will be removed in v13")
let int_of_string_opt = s =>
switch int_of_string(s) {
| n if n == %raw("NaN") => None
| n => Some(n)
}
@deprecated("Use `String.get` instead. This will be removed in v13")
external string_get: (string, int) => char = "%string_safe_get"
/* List operations -- more in module List */
@deprecated("Use `List.concat` instead. This will be removed in v13")
let rec \"@" = (l1, l2) =>
switch l1 {
| list{} => l2
| list{hd, ...tl} => list{hd, ...\"@"(tl, l2)}
}
/* Miscellaneous */
@deprecated("This will be removed in v13")
type int32 = int