@grain/stdlib 0.5.13 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +193 -0
- package/LICENSE +1 -1
- package/README.md +25 -2
- package/array.gr +1512 -199
- package/array.md +2032 -94
- package/bigint.gr +239 -140
- package/bigint.md +450 -106
- package/buffer.gr +595 -102
- package/buffer.md +903 -145
- package/bytes.gr +401 -110
- package/bytes.md +551 -63
- package/char.gr +228 -49
- package/char.md +373 -7
- package/exception.gr +26 -12
- package/exception.md +29 -5
- package/float32.gr +130 -109
- package/float32.md +185 -57
- package/float64.gr +112 -99
- package/float64.md +185 -57
- package/hash.gr +47 -37
- package/hash.md +21 -3
- package/int16.gr +430 -0
- package/int16.md +618 -0
- package/int32.gr +200 -269
- package/int32.md +254 -289
- package/int64.gr +142 -225
- package/int64.md +254 -289
- package/int8.gr +511 -0
- package/int8.md +786 -0
- package/json.gr +2084 -0
- package/json.md +608 -0
- package/list.gr +120 -68
- package/list.md +125 -80
- package/map.gr +560 -57
- package/map.md +672 -56
- package/marshal.gr +239 -227
- package/marshal.md +36 -4
- package/number.gr +626 -676
- package/number.md +738 -153
- package/option.gr +33 -35
- package/option.md +58 -42
- package/package.json +2 -2
- package/path.gr +148 -187
- package/path.md +47 -96
- package/pervasives.gr +75 -416
- package/pervasives.md +85 -180
- package/priorityqueue.gr +433 -74
- package/priorityqueue.md +422 -54
- package/queue.gr +362 -80
- package/queue.md +433 -38
- package/random.gr +67 -75
- package/random.md +68 -40
- package/range.gr +135 -63
- package/range.md +198 -43
- package/rational.gr +284 -0
- package/rational.md +545 -0
- package/regex.gr +933 -1066
- package/regex.md +59 -60
- package/result.gr +23 -25
- package/result.md +54 -39
- package/runtime/atof/common.gr +78 -82
- package/runtime/atof/common.md +22 -10
- package/runtime/atof/decimal.gr +102 -127
- package/runtime/atof/decimal.md +28 -7
- package/runtime/atof/lemire.gr +56 -71
- package/runtime/atof/lemire.md +9 -1
- package/runtime/atof/parse.gr +83 -110
- package/runtime/atof/parse.md +12 -2
- package/runtime/atof/slow.gr +28 -35
- package/runtime/atof/slow.md +9 -1
- package/runtime/atof/table.gr +19 -18
- package/runtime/atof/table.md +10 -2
- package/runtime/atoi/parse.gr +153 -136
- package/runtime/atoi/parse.md +50 -1
- package/runtime/bigint.gr +410 -517
- package/runtime/bigint.md +71 -57
- package/runtime/compare.gr +176 -85
- package/runtime/compare.md +31 -1
- package/runtime/dataStructures.gr +144 -32
- package/runtime/dataStructures.md +267 -31
- package/runtime/debugPrint.gr +34 -15
- package/runtime/debugPrint.md +37 -5
- package/runtime/equal.gr +53 -52
- package/runtime/equal.md +30 -1
- package/runtime/exception.gr +38 -47
- package/runtime/exception.md +10 -8
- package/runtime/gc.gr +23 -152
- package/runtime/gc.md +13 -17
- package/runtime/malloc.gr +31 -31
- package/runtime/malloc.md +11 -3
- package/runtime/numberUtils.gr +191 -172
- package/runtime/numberUtils.md +17 -9
- package/runtime/numbers.gr +1695 -1021
- package/runtime/numbers.md +1098 -134
- package/runtime/string.gr +540 -242
- package/runtime/string.md +76 -6
- package/runtime/unsafe/constants.gr +30 -13
- package/runtime/unsafe/constants.md +80 -0
- package/runtime/unsafe/conv.gr +55 -28
- package/runtime/unsafe/conv.md +41 -9
- package/runtime/unsafe/memory.gr +10 -30
- package/runtime/unsafe/memory.md +15 -19
- package/runtime/unsafe/tags.gr +37 -21
- package/runtime/unsafe/tags.md +88 -8
- package/runtime/unsafe/wasmf32.gr +30 -36
- package/runtime/unsafe/wasmf32.md +64 -56
- package/runtime/unsafe/wasmf64.gr +30 -36
- package/runtime/unsafe/wasmf64.md +64 -56
- package/runtime/unsafe/wasmi32.gr +49 -66
- package/runtime/unsafe/wasmi32.md +102 -94
- package/runtime/unsafe/wasmi64.gr +52 -79
- package/runtime/unsafe/wasmi64.md +108 -100
- package/runtime/utils/printing.gr +13 -15
- package/runtime/utils/printing.md +11 -3
- package/runtime/wasi.gr +294 -295
- package/runtime/wasi.md +62 -42
- package/set.gr +574 -64
- package/set.md +634 -54
- package/stack.gr +181 -64
- package/stack.md +271 -42
- package/string.gr +453 -533
- package/string.md +241 -151
- package/uint16.gr +369 -0
- package/uint16.md +585 -0
- package/uint32.gr +470 -0
- package/uint32.md +737 -0
- package/uint64.gr +471 -0
- package/uint64.md +737 -0
- package/uint8.gr +369 -0
- package/uint8.md +585 -0
- package/uri.gr +1093 -0
- package/uri.md +477 -0
- package/{sys → wasi}/file.gr +914 -500
- package/{sys → wasi}/file.md +454 -50
- package/wasi/process.gr +292 -0
- package/{sys → wasi}/process.md +164 -6
- package/wasi/random.gr +77 -0
- package/wasi/random.md +80 -0
- package/{sys → wasi}/time.gr +15 -22
- package/{sys → wasi}/time.md +5 -5
- package/immutablearray.gr +0 -929
- package/immutablearray.md +0 -1038
- package/immutablemap.gr +0 -493
- package/immutablemap.md +0 -479
- package/immutablepriorityqueue.gr +0 -360
- package/immutablepriorityqueue.md +0 -291
- package/immutableset.gr +0 -498
- package/immutableset.md +0 -449
- package/runtime/debug.gr +0 -2
- package/runtime/debug.md +0 -6
- package/runtime/unsafe/errors.gr +0 -36
- package/runtime/unsafe/errors.md +0 -204
- package/sys/process.gr +0 -254
- package/sys/random.gr +0 -79
- package/sys/random.md +0 -66
package/pervasives.md
CHANGED
|
@@ -10,50 +10,12 @@ No other changes yet.
|
|
|
10
10
|
</details>
|
|
11
11
|
|
|
12
12
|
```grain
|
|
13
|
-
|
|
13
|
+
from "pervasives" include Pervasives
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
##
|
|
16
|
+
## Values
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
### Pervasives.**List**
|
|
21
|
-
|
|
22
|
-
```grain
|
|
23
|
-
enum List<a> {
|
|
24
|
-
[],
|
|
25
|
-
[...](a, List<a>),
|
|
26
|
-
}
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
The type of Grain lists.
|
|
30
|
-
|
|
31
|
-
### Pervasives.**Option**
|
|
32
|
-
|
|
33
|
-
```grain
|
|
34
|
-
enum Option<a> {
|
|
35
|
-
Some(a),
|
|
36
|
-
None,
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
Grain's type representing something that may or may not contain data.
|
|
41
|
-
Think of this like a better, type-safe "null".
|
|
42
|
-
|
|
43
|
-
### Pervasives.**Result**
|
|
44
|
-
|
|
45
|
-
```grain
|
|
46
|
-
enum Result<t, e> {
|
|
47
|
-
Ok(t),
|
|
48
|
-
Err(e),
|
|
49
|
-
}
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
Grain's type representing the result of something that might error.
|
|
53
|
-
|
|
54
|
-
## Boolean operations
|
|
55
|
-
|
|
56
|
-
Infix functions for working with Boolean values.
|
|
18
|
+
Functions and constants included in the Pervasives module.
|
|
57
19
|
|
|
58
20
|
### Pervasives.**(!)**
|
|
59
21
|
|
|
@@ -63,7 +25,7 @@ No other changes yet.
|
|
|
63
25
|
</details>
|
|
64
26
|
|
|
65
27
|
```grain
|
|
66
|
-
(!) : Bool
|
|
28
|
+
(!) : (bool: Bool) => Bool
|
|
67
29
|
```
|
|
68
30
|
|
|
69
31
|
Computes the logical NOT (`!`) of the given operand.
|
|
@@ -73,7 +35,7 @@ Parameters:
|
|
|
73
35
|
|
|
74
36
|
|param|type|description|
|
|
75
37
|
|-----|----|-----------|
|
|
76
|
-
|`
|
|
38
|
+
|`bool`|`Bool`|The operand|
|
|
77
39
|
|
|
78
40
|
Returns:
|
|
79
41
|
|
|
@@ -99,7 +61,7 @@ No other changes yet.
|
|
|
99
61
|
</details>
|
|
100
62
|
|
|
101
63
|
```grain
|
|
102
|
-
(&&) : (Bool, Bool)
|
|
64
|
+
(&&) : (left: Bool, right: Bool) => Bool
|
|
103
65
|
```
|
|
104
66
|
|
|
105
67
|
Computes the logical AND (`&&`) of the given operands.
|
|
@@ -111,8 +73,8 @@ Parameters:
|
|
|
111
73
|
|
|
112
74
|
|param|type|description|
|
|
113
75
|
|-----|----|-----------|
|
|
114
|
-
|`
|
|
115
|
-
|`
|
|
76
|
+
|`left`|`Bool`|The first operand|
|
|
77
|
+
|`right`|`Bool`|The second operand|
|
|
116
78
|
|
|
117
79
|
Returns:
|
|
118
80
|
|
|
@@ -128,7 +90,7 @@ No other changes yet.
|
|
|
128
90
|
</details>
|
|
129
91
|
|
|
130
92
|
```grain
|
|
131
|
-
(||) : (Bool, Bool)
|
|
93
|
+
(||) : (left: Bool, right: Bool) => Bool
|
|
132
94
|
```
|
|
133
95
|
|
|
134
96
|
Computes the logical OR `||` of the given operands.
|
|
@@ -140,8 +102,8 @@ Parameters:
|
|
|
140
102
|
|
|
141
103
|
|param|type|description|
|
|
142
104
|
|-----|----|-----------|
|
|
143
|
-
|`
|
|
144
|
-
|`
|
|
105
|
+
|`left`|`Bool`|The first operand|
|
|
106
|
+
|`right`|`Bool`|The second operand|
|
|
145
107
|
|
|
146
108
|
Returns:
|
|
147
109
|
|
|
@@ -149,10 +111,6 @@ Returns:
|
|
|
149
111
|
|----|-----------|
|
|
150
112
|
|`Bool`|The first operand if it is `true` or the value of the second operand otherwise|
|
|
151
113
|
|
|
152
|
-
## Comparison operations
|
|
153
|
-
|
|
154
|
-
Infix functions for comparing values.
|
|
155
|
-
|
|
156
114
|
### Pervasives.**(==)**
|
|
157
115
|
|
|
158
116
|
<details disabled>
|
|
@@ -161,7 +119,7 @@ No other changes yet.
|
|
|
161
119
|
</details>
|
|
162
120
|
|
|
163
121
|
```grain
|
|
164
|
-
(==) : (a, a)
|
|
122
|
+
(==) : (value1: a, value2: a) => Bool
|
|
165
123
|
```
|
|
166
124
|
|
|
167
125
|
Check that two values are equal. This checks for structural equality,
|
|
@@ -188,7 +146,7 @@ No other changes yet.
|
|
|
188
146
|
</details>
|
|
189
147
|
|
|
190
148
|
```grain
|
|
191
|
-
(!=) : (a, a)
|
|
149
|
+
(!=) : (value1: a, value2: a) => Bool
|
|
192
150
|
```
|
|
193
151
|
|
|
194
152
|
Check that two values are **not** equal. This checks for structural equality,
|
|
@@ -215,7 +173,7 @@ No other changes yet.
|
|
|
215
173
|
</details>
|
|
216
174
|
|
|
217
175
|
```grain
|
|
218
|
-
is : (a, a)
|
|
176
|
+
is : (left: a, right: a) => Bool
|
|
219
177
|
```
|
|
220
178
|
|
|
221
179
|
Checks that two values are physically equal.
|
|
@@ -225,8 +183,8 @@ Parameters:
|
|
|
225
183
|
|
|
226
184
|
|param|type|description|
|
|
227
185
|
|-----|----|-----------|
|
|
228
|
-
|`
|
|
229
|
-
|`
|
|
186
|
+
|`left`|`a`|The first operand|
|
|
187
|
+
|`right`|`a`|The second operand|
|
|
230
188
|
|
|
231
189
|
Returns:
|
|
232
190
|
|
|
@@ -242,7 +200,7 @@ No other changes yet.
|
|
|
242
200
|
</details>
|
|
243
201
|
|
|
244
202
|
```grain
|
|
245
|
-
isnt : (a, a)
|
|
203
|
+
isnt : (value1: a, value2: a) => Bool
|
|
246
204
|
```
|
|
247
205
|
|
|
248
206
|
Checks that two values are **not** physically equal.
|
|
@@ -261,10 +219,6 @@ Returns:
|
|
|
261
219
|
|----|-----------|
|
|
262
220
|
|`Bool`|`false` if the values are physically equal or `true` otherwise|
|
|
263
221
|
|
|
264
|
-
## Number comparisons
|
|
265
|
-
|
|
266
|
-
Infix functions for comparing Number values.
|
|
267
|
-
|
|
268
222
|
### Pervasives.**(<)**
|
|
269
223
|
|
|
270
224
|
<details disabled>
|
|
@@ -273,7 +227,7 @@ No other changes yet.
|
|
|
273
227
|
</details>
|
|
274
228
|
|
|
275
229
|
```grain
|
|
276
|
-
(<) : (Number, Number)
|
|
230
|
+
(<) : (num1: Number, num2: Number) => Bool
|
|
277
231
|
```
|
|
278
232
|
|
|
279
233
|
Checks if the first operand is less than the second operand.
|
|
@@ -299,7 +253,7 @@ No other changes yet.
|
|
|
299
253
|
</details>
|
|
300
254
|
|
|
301
255
|
```grain
|
|
302
|
-
(>) : (Number, Number)
|
|
256
|
+
(>) : (num1: Number, num2: Number) => Bool
|
|
303
257
|
```
|
|
304
258
|
|
|
305
259
|
Checks if the first operand is greater than the second operand.
|
|
@@ -325,7 +279,7 @@ No other changes yet.
|
|
|
325
279
|
</details>
|
|
326
280
|
|
|
327
281
|
```grain
|
|
328
|
-
(<=) : (Number, Number)
|
|
282
|
+
(<=) : (num1: Number, num2: Number) => Bool
|
|
329
283
|
```
|
|
330
284
|
|
|
331
285
|
Checks if the first operand is less than or equal to the second operand.
|
|
@@ -351,7 +305,7 @@ No other changes yet.
|
|
|
351
305
|
</details>
|
|
352
306
|
|
|
353
307
|
```grain
|
|
354
|
-
(>=) : (Number, Number)
|
|
308
|
+
(>=) : (num1: Number, num2: Number) => Bool
|
|
355
309
|
```
|
|
356
310
|
|
|
357
311
|
Checks if the first operand is greater than or equal to the second operand.
|
|
@@ -377,7 +331,7 @@ No other changes yet.
|
|
|
377
331
|
</details>
|
|
378
332
|
|
|
379
333
|
```grain
|
|
380
|
-
compare : (a, a)
|
|
334
|
+
compare : (num1: a, num2: a) => Number
|
|
381
335
|
```
|
|
382
336
|
|
|
383
337
|
Compares the first argument to the second argument and produces an integer result.
|
|
@@ -397,10 +351,6 @@ Returns:
|
|
|
397
351
|
|----|-----------|
|
|
398
352
|
|`Number`|A negative integer if the first operand is less than the second operand, `0` if they are equal, or a positive integer otherwise|
|
|
399
353
|
|
|
400
|
-
## Math operations
|
|
401
|
-
|
|
402
|
-
Infix functions for working with Number values.
|
|
403
|
-
|
|
404
354
|
### Pervasives.**(+)**
|
|
405
355
|
|
|
406
356
|
<details disabled>
|
|
@@ -409,7 +359,7 @@ No other changes yet.
|
|
|
409
359
|
</details>
|
|
410
360
|
|
|
411
361
|
```grain
|
|
412
|
-
(+) : (Number, Number)
|
|
362
|
+
(+) : (num1: Number, num2: Number) => Number
|
|
413
363
|
```
|
|
414
364
|
|
|
415
365
|
Computes the sum of its operands.
|
|
@@ -435,7 +385,7 @@ No other changes yet.
|
|
|
435
385
|
</details>
|
|
436
386
|
|
|
437
387
|
```grain
|
|
438
|
-
(-) : (Number, Number)
|
|
388
|
+
(-) : (num1: Number, num2: Number) => Number
|
|
439
389
|
```
|
|
440
390
|
|
|
441
391
|
Computes the difference of its operands.
|
|
@@ -461,7 +411,7 @@ No other changes yet.
|
|
|
461
411
|
</details>
|
|
462
412
|
|
|
463
413
|
```grain
|
|
464
|
-
(*) : (Number, Number)
|
|
414
|
+
(*) : (num1: Number, num2: Number) => Number
|
|
465
415
|
```
|
|
466
416
|
|
|
467
417
|
Computes the product of its operands.
|
|
@@ -487,7 +437,7 @@ No other changes yet.
|
|
|
487
437
|
</details>
|
|
488
438
|
|
|
489
439
|
```grain
|
|
490
|
-
(/) : (Number, Number)
|
|
440
|
+
(/) : (num1: Number, num2: Number) => Number
|
|
491
441
|
```
|
|
492
442
|
|
|
493
443
|
Computes the quotient of its operands.
|
|
@@ -513,7 +463,7 @@ No other changes yet.
|
|
|
513
463
|
</details>
|
|
514
464
|
|
|
515
465
|
```grain
|
|
516
|
-
(%) : (Number, Number)
|
|
466
|
+
(%) : (num1: Number, num2: Number) => Number
|
|
517
467
|
```
|
|
518
468
|
|
|
519
469
|
Computes the remainder of the division of the first operand by the second.
|
|
@@ -532,6 +482,39 @@ Returns:
|
|
|
532
482
|
|----|-----------|
|
|
533
483
|
|`Number`|The modulus of its operands|
|
|
534
484
|
|
|
485
|
+
### Pervasives.**(\*\*)**
|
|
486
|
+
|
|
487
|
+
<details>
|
|
488
|
+
<summary>Added in <code>0.6.0</code></summary>
|
|
489
|
+
<table>
|
|
490
|
+
<thead>
|
|
491
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
492
|
+
</thead>
|
|
493
|
+
<tbody>
|
|
494
|
+
<tr><td><code>0.5.4</code></td><td>Originally existed in Number module</td></tr>
|
|
495
|
+
</tbody>
|
|
496
|
+
</table>
|
|
497
|
+
</details>
|
|
498
|
+
|
|
499
|
+
```grain
|
|
500
|
+
(**) : (base: Number, power: Number) => Number
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Computes the exponentiation of the given base and power.
|
|
504
|
+
|
|
505
|
+
Parameters:
|
|
506
|
+
|
|
507
|
+
|param|type|description|
|
|
508
|
+
|-----|----|-----------|
|
|
509
|
+
|`base`|`Number`|The base number|
|
|
510
|
+
|`power`|`Number`|The exponent number|
|
|
511
|
+
|
|
512
|
+
Returns:
|
|
513
|
+
|
|
514
|
+
|type|description|
|
|
515
|
+
|----|-----------|
|
|
516
|
+
|`Number`|The base raised to the given power|
|
|
517
|
+
|
|
535
518
|
### Pervasives.**incr**
|
|
536
519
|
|
|
537
520
|
<details disabled>
|
|
@@ -540,7 +523,7 @@ No other changes yet.
|
|
|
540
523
|
</details>
|
|
541
524
|
|
|
542
525
|
```grain
|
|
543
|
-
incr : Number
|
|
526
|
+
incr : (value: Number) => Number
|
|
544
527
|
```
|
|
545
528
|
|
|
546
529
|
Increments the value by one.
|
|
@@ -565,7 +548,7 @@ No other changes yet.
|
|
|
565
548
|
</details>
|
|
566
549
|
|
|
567
550
|
```grain
|
|
568
|
-
decr : Number
|
|
551
|
+
decr : (value: Number) => Number
|
|
569
552
|
```
|
|
570
553
|
|
|
571
554
|
Decrements the value by one.
|
|
@@ -582,10 +565,6 @@ Returns:
|
|
|
582
565
|
|----|-----------|
|
|
583
566
|
|`Number`|The decremented value|
|
|
584
567
|
|
|
585
|
-
## String operations
|
|
586
|
-
|
|
587
|
-
Infix functions for operating on String values.
|
|
588
|
-
|
|
589
568
|
### Pervasives.**(++)**
|
|
590
569
|
|
|
591
570
|
<details disabled>
|
|
@@ -594,7 +573,7 @@ No other changes yet.
|
|
|
594
573
|
</details>
|
|
595
574
|
|
|
596
575
|
```grain
|
|
597
|
-
(++) : (String, String)
|
|
576
|
+
(++) : (str1: String, str2: String) => String
|
|
598
577
|
```
|
|
599
578
|
|
|
600
579
|
Concatenate two strings.
|
|
@@ -618,10 +597,6 @@ Examples:
|
|
|
618
597
|
"Foo" ++ "Bar" == "FooBar"
|
|
619
598
|
```
|
|
620
599
|
|
|
621
|
-
## Bitwise operations
|
|
622
|
-
|
|
623
|
-
Infix functions for operating on bits of Number values.
|
|
624
|
-
|
|
625
600
|
### Pervasives.**lnot**
|
|
626
601
|
|
|
627
602
|
<details disabled>
|
|
@@ -630,7 +605,7 @@ No other changes yet.
|
|
|
630
605
|
</details>
|
|
631
606
|
|
|
632
607
|
```grain
|
|
633
|
-
lnot : Number
|
|
608
|
+
lnot : (value: Number) => Number
|
|
634
609
|
```
|
|
635
610
|
|
|
636
611
|
Computes the bitwise NOT of the operand.
|
|
@@ -663,7 +638,7 @@ Returns:
|
|
|
663
638
|
</details>
|
|
664
639
|
|
|
665
640
|
```grain
|
|
666
|
-
(&) : (Number, Number)
|
|
641
|
+
(&) : (value1: Number, value2: Number) => Number
|
|
667
642
|
```
|
|
668
643
|
|
|
669
644
|
Computes the bitwise AND (`&`) on the given operands.
|
|
@@ -697,7 +672,7 @@ Returns:
|
|
|
697
672
|
</details>
|
|
698
673
|
|
|
699
674
|
```grain
|
|
700
|
-
(|) : (Number, Number)
|
|
675
|
+
(|) : (value1: Number, value2: Number) => Number
|
|
701
676
|
```
|
|
702
677
|
|
|
703
678
|
Computes the bitwise OR (`|`) on the given operands.
|
|
@@ -732,7 +707,7 @@ Returns:
|
|
|
732
707
|
</details>
|
|
733
708
|
|
|
734
709
|
```grain
|
|
735
|
-
(^) : (Number, Number)
|
|
710
|
+
(^) : (value1: Number, value2: Number) => Number
|
|
736
711
|
```
|
|
737
712
|
|
|
738
713
|
Computes the bitwise XOR (`^`) on the given operands.
|
|
@@ -766,7 +741,7 @@ Returns:
|
|
|
766
741
|
</details>
|
|
767
742
|
|
|
768
743
|
```grain
|
|
769
|
-
(<<) : (Number, Number)
|
|
744
|
+
(<<) : (value: Number, amount: Number) => Number
|
|
770
745
|
```
|
|
771
746
|
|
|
772
747
|
Shifts the bits of the value left by the given number of bits.
|
|
@@ -800,7 +775,7 @@ Returns:
|
|
|
800
775
|
</details>
|
|
801
776
|
|
|
802
777
|
```grain
|
|
803
|
-
(>>>) : (Number, Number)
|
|
778
|
+
(>>>) : (value: Number, amount: Number) => Number
|
|
804
779
|
```
|
|
805
780
|
|
|
806
781
|
Shifts the bits of the value right by the given number of bits, preserving the sign bit.
|
|
@@ -834,7 +809,7 @@ Returns:
|
|
|
834
809
|
</details>
|
|
835
810
|
|
|
836
811
|
```grain
|
|
837
|
-
(>>) : (Number, Number)
|
|
812
|
+
(>>) : (value: Number, amount: Number) => Number
|
|
838
813
|
```
|
|
839
814
|
|
|
840
815
|
Shifts the bits of the value right by the given number of bits.
|
|
@@ -852,10 +827,6 @@ Returns:
|
|
|
852
827
|
|----|-----------|
|
|
853
828
|
|`Number`|The shifted value|
|
|
854
829
|
|
|
855
|
-
## Printing
|
|
856
|
-
|
|
857
|
-
Functions that deal with printing.
|
|
858
|
-
|
|
859
830
|
### Pervasives.**toString**
|
|
860
831
|
|
|
861
832
|
<details disabled>
|
|
@@ -864,11 +835,11 @@ No other changes yet.
|
|
|
864
835
|
</details>
|
|
865
836
|
|
|
866
837
|
```grain
|
|
867
|
-
toString : a
|
|
838
|
+
toString : (value: a) => String
|
|
868
839
|
```
|
|
869
840
|
|
|
870
841
|
Converts the given operand to a string.
|
|
871
|
-
Provides a better representation of data types if those types are
|
|
842
|
+
Provides a better representation of data types if those types are provided from the module.
|
|
872
843
|
|
|
873
844
|
Parameters:
|
|
874
845
|
|
|
@@ -890,22 +861,19 @@ No other changes yet.
|
|
|
890
861
|
</details>
|
|
891
862
|
|
|
892
863
|
```grain
|
|
893
|
-
print : a
|
|
864
|
+
print : (value: a, ?suffix: String) => Void
|
|
894
865
|
```
|
|
895
866
|
|
|
896
867
|
Prints the given operand to the console. Works for any type. Internally, calls `toString`
|
|
897
868
|
on the operand, so a better representation of data type will be printed if those types
|
|
898
|
-
are
|
|
869
|
+
are provided from the module.
|
|
899
870
|
|
|
900
871
|
Parameters:
|
|
901
872
|
|
|
902
873
|
|param|type|description|
|
|
903
874
|
|-----|----|-----------|
|
|
904
875
|
|`value`|`a`|The operand|
|
|
905
|
-
|
|
906
|
-
## Type helpers
|
|
907
|
-
|
|
908
|
-
Functions that help with typechecking.
|
|
876
|
+
|`?suffix`|`String`|The string to print after the argument|
|
|
909
877
|
|
|
910
878
|
### Pervasives.**ignore**
|
|
911
879
|
|
|
@@ -915,7 +883,7 @@ No other changes yet.
|
|
|
915
883
|
</details>
|
|
916
884
|
|
|
917
885
|
```grain
|
|
918
|
-
ignore : a
|
|
886
|
+
ignore : (value: a) => Void
|
|
919
887
|
```
|
|
920
888
|
|
|
921
889
|
Accepts any value and always returns `void`.
|
|
@@ -926,10 +894,6 @@ Parameters:
|
|
|
926
894
|
|-----|----|-----------|
|
|
927
895
|
|`value`|`a`|The value to ignore|
|
|
928
896
|
|
|
929
|
-
## Assertions
|
|
930
|
-
|
|
931
|
-
Functions that raise if conditions are not met.
|
|
932
|
-
|
|
933
897
|
### Pervasives.**assert**
|
|
934
898
|
|
|
935
899
|
<details disabled>
|
|
@@ -938,7 +902,7 @@ No other changes yet.
|
|
|
938
902
|
</details>
|
|
939
903
|
|
|
940
904
|
```grain
|
|
941
|
-
assert : Bool
|
|
905
|
+
assert : (condition: Bool) => Void
|
|
942
906
|
```
|
|
943
907
|
|
|
944
908
|
Assert that the given Boolean condition is `true`.
|
|
@@ -965,10 +929,6 @@ assert 3 > 2
|
|
|
965
929
|
assert true
|
|
966
930
|
```
|
|
967
931
|
|
|
968
|
-
## Failures
|
|
969
|
-
|
|
970
|
-
Functions that throw an Exception unconditionally.
|
|
971
|
-
|
|
972
932
|
### Pervasives.**throw**
|
|
973
933
|
|
|
974
934
|
<details disabled>
|
|
@@ -977,7 +937,7 @@ No other changes yet.
|
|
|
977
937
|
</details>
|
|
978
938
|
|
|
979
939
|
```grain
|
|
980
|
-
throw : Exception
|
|
940
|
+
throw : (exn: Exception) => a
|
|
981
941
|
```
|
|
982
942
|
|
|
983
943
|
Throw an exception. Currently, exceptions cannot be caught and will crash your program.
|
|
@@ -986,7 +946,7 @@ Parameters:
|
|
|
986
946
|
|
|
987
947
|
|param|type|description|
|
|
988
948
|
|-----|----|-----------|
|
|
989
|
-
|`
|
|
949
|
+
|`exn`|`Exception`|The exception to be thrown|
|
|
990
950
|
|
|
991
951
|
Returns:
|
|
992
952
|
|
|
@@ -997,7 +957,7 @@ Returns:
|
|
|
997
957
|
### Pervasives.**fail**
|
|
998
958
|
|
|
999
959
|
```grain
|
|
1000
|
-
fail : String
|
|
960
|
+
fail : (message: String) => a
|
|
1001
961
|
```
|
|
1002
962
|
|
|
1003
963
|
Unconditionally throw a `Failure` exception with a message.
|
|
@@ -1015,10 +975,6 @@ Returns:
|
|
|
1015
975
|
|----|-----------|
|
|
1016
976
|
|`a`|Anything and nothing—your program won't continue past a fail expression|
|
|
1017
977
|
|
|
1018
|
-
## Other
|
|
1019
|
-
|
|
1020
|
-
Other functions on values.
|
|
1021
|
-
|
|
1022
978
|
### Pervasives.**identity**
|
|
1023
979
|
|
|
1024
980
|
<details disabled>
|
|
@@ -1027,7 +983,7 @@ No other changes yet.
|
|
|
1027
983
|
</details>
|
|
1028
984
|
|
|
1029
985
|
```grain
|
|
1030
|
-
identity : a
|
|
986
|
+
identity : (value: a) => a
|
|
1031
987
|
```
|
|
1032
988
|
|
|
1033
989
|
Provides the operand untouched.
|
|
@@ -1044,10 +1000,6 @@ Returns:
|
|
|
1044
1000
|
|----|-----------|
|
|
1045
1001
|
|`a`|The value untouched|
|
|
1046
1002
|
|
|
1047
|
-
## Box operations
|
|
1048
|
-
|
|
1049
|
-
Functions for working with Box values.
|
|
1050
|
-
|
|
1051
1003
|
### Pervasives.**box**
|
|
1052
1004
|
|
|
1053
1005
|
<details disabled>
|
|
@@ -1056,7 +1008,7 @@ No other changes yet.
|
|
|
1056
1008
|
</details>
|
|
1057
1009
|
|
|
1058
1010
|
```grain
|
|
1059
|
-
box : a
|
|
1011
|
+
box : (value: a) => Box<a>
|
|
1060
1012
|
```
|
|
1061
1013
|
|
|
1062
1014
|
Creates a box containing the given initial value.
|
|
@@ -1067,7 +1019,7 @@ Parameters:
|
|
|
1067
1019
|
|
|
1068
1020
|
|param|type|description|
|
|
1069
1021
|
|-----|----|-----------|
|
|
1070
|
-
|`
|
|
1022
|
+
|`value`|`a`|The initial value inside the box|
|
|
1071
1023
|
|
|
1072
1024
|
Returns:
|
|
1073
1025
|
|
|
@@ -1083,7 +1035,7 @@ No other changes yet.
|
|
|
1083
1035
|
</details>
|
|
1084
1036
|
|
|
1085
1037
|
```grain
|
|
1086
|
-
unbox : Box<a>
|
|
1038
|
+
unbox : (value: Box<a>) => a
|
|
1087
1039
|
```
|
|
1088
1040
|
|
|
1089
1041
|
Retrieves the current value from a box.
|
|
@@ -1092,7 +1044,7 @@ Parameters:
|
|
|
1092
1044
|
|
|
1093
1045
|
|param|type|description|
|
|
1094
1046
|
|-----|----|-----------|
|
|
1095
|
-
|`
|
|
1047
|
+
|`value`|`Box<a>`|The box to unwrap|
|
|
1096
1048
|
|
|
1097
1049
|
Returns:
|
|
1098
1050
|
|
|
@@ -1100,50 +1052,3 @@ Returns:
|
|
|
1100
1052
|
|----|-----------|
|
|
1101
1053
|
|`a`|The value inside the box|
|
|
1102
1054
|
|
|
1103
|
-
## List operations
|
|
1104
|
-
|
|
1105
|
-
Functions for working with List values.
|
|
1106
|
-
|
|
1107
|
-
### Pervasives.**cons**
|
|
1108
|
-
|
|
1109
|
-
> **Deprecated:** This will be removed in a future release of Grain.
|
|
1110
|
-
|
|
1111
|
-
<details disabled>
|
|
1112
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
1113
|
-
No other changes yet.
|
|
1114
|
-
</details>
|
|
1115
|
-
|
|
1116
|
-
```grain
|
|
1117
|
-
cons : (a, List<a>) -> List<a>
|
|
1118
|
-
```
|
|
1119
|
-
|
|
1120
|
-
The list spread syntax (`[a, ...b]`) provided as a function.
|
|
1121
|
-
|
|
1122
|
-
Parameters:
|
|
1123
|
-
|
|
1124
|
-
|param|type|description|
|
|
1125
|
-
|-----|----|-----------|
|
|
1126
|
-
|`a`|`a`|The head of the list|
|
|
1127
|
-
|`b`|`List<a>`|The tail of the list|
|
|
1128
|
-
|
|
1129
|
-
Returns:
|
|
1130
|
-
|
|
1131
|
-
|type|description|
|
|
1132
|
-
|----|-----------|
|
|
1133
|
-
|`List<a>`|The new list|
|
|
1134
|
-
|
|
1135
|
-
### Pervasives.**empty**
|
|
1136
|
-
|
|
1137
|
-
> **Deprecated:** This will be removed in a future release of Grain.
|
|
1138
|
-
|
|
1139
|
-
<details disabled>
|
|
1140
|
-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
|
|
1141
|
-
No other changes yet.
|
|
1142
|
-
</details>
|
|
1143
|
-
|
|
1144
|
-
```grain
|
|
1145
|
-
empty : List<a>
|
|
1146
|
-
```
|
|
1147
|
-
|
|
1148
|
-
The empty list syntax (`[]`) provided as a value.
|
|
1149
|
-
|