@grain/stdlib 0.4.6 → 0.5.2

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/array.gr +18 -18
  3. package/array.md +18 -18
  4. package/bigint.gr +497 -0
  5. package/bigint.md +811 -0
  6. package/buffer.gr +59 -223
  7. package/buffer.md +24 -17
  8. package/bytes.gr +100 -202
  9. package/bytes.md +19 -0
  10. package/char.gr +63 -133
  11. package/exception.gr +28 -2
  12. package/exception.md +43 -0
  13. package/float32.gr +76 -95
  14. package/float32.md +69 -30
  15. package/float64.gr +81 -95
  16. package/float64.md +69 -30
  17. package/hash.gr +37 -37
  18. package/int32.gr +152 -198
  19. package/int32.md +104 -0
  20. package/int64.gr +151 -197
  21. package/int64.md +104 -0
  22. package/list.gr +467 -70
  23. package/list.md +1141 -0
  24. package/map.gr +192 -7
  25. package/map.md +525 -0
  26. package/number.gr +111 -54
  27. package/number.md +100 -3
  28. package/option.md +1 -1
  29. package/package.json +3 -3
  30. package/pervasives.gr +499 -59
  31. package/pervasives.md +1116 -0
  32. package/queue.gr +4 -0
  33. package/queue.md +10 -0
  34. package/random.gr +196 -0
  35. package/random.md +179 -0
  36. package/regex.gr +1833 -842
  37. package/regex.md +11 -11
  38. package/result.md +1 -1
  39. package/runtime/bigint.gr +2045 -0
  40. package/runtime/bigint.md +326 -0
  41. package/runtime/dataStructures.gr +99 -278
  42. package/runtime/dataStructures.md +391 -0
  43. package/runtime/debug.md +6 -0
  44. package/runtime/equal.gr +5 -23
  45. package/runtime/equal.md +6 -0
  46. package/runtime/exception.md +30 -0
  47. package/runtime/gc.gr +20 -3
  48. package/runtime/gc.md +36 -0
  49. package/runtime/malloc.gr +13 -11
  50. package/runtime/malloc.md +55 -0
  51. package/runtime/numberUtils.gr +91 -41
  52. package/runtime/numberUtils.md +54 -0
  53. package/runtime/numbers.gr +1049 -391
  54. package/runtime/numbers.md +300 -0
  55. package/runtime/string.gr +136 -230
  56. package/runtime/string.md +24 -0
  57. package/runtime/stringUtils.gr +58 -38
  58. package/runtime/stringUtils.md +6 -0
  59. package/runtime/unsafe/constants.gr +17 -0
  60. package/runtime/unsafe/constants.md +72 -0
  61. package/runtime/unsafe/conv.md +71 -0
  62. package/runtime/unsafe/errors.md +204 -0
  63. package/runtime/unsafe/memory.md +54 -0
  64. package/runtime/unsafe/printWasm.md +24 -0
  65. package/runtime/unsafe/tags.gr +9 -8
  66. package/runtime/unsafe/tags.md +120 -0
  67. package/runtime/unsafe/wasmf32.md +168 -0
  68. package/runtime/unsafe/wasmf64.md +168 -0
  69. package/runtime/unsafe/wasmi32.md +282 -0
  70. package/runtime/unsafe/wasmi64.md +300 -0
  71. package/runtime/utils/printing.gr +62 -0
  72. package/runtime/utils/printing.md +18 -0
  73. package/runtime/wasi.gr +1 -1
  74. package/runtime/wasi.md +839 -0
  75. package/set.gr +17 -8
  76. package/set.md +24 -21
  77. package/stack.gr +3 -3
  78. package/stack.md +4 -6
  79. package/string.gr +194 -329
  80. package/string.md +3 -3
  81. package/sys/file.gr +245 -429
  82. package/sys/process.gr +27 -45
  83. package/sys/random.gr +47 -16
  84. package/sys/random.md +38 -0
  85. package/sys/time.gr +11 -27
package/pervasives.md ADDED
@@ -0,0 +1,1116 @@
1
+ ---
2
+ title: Pervasives
3
+ ---
4
+
5
+ This module is automatically imported into every Grain program. You can think of it as the global environment. Although it is automatically imported, it can still be imported manually.
6
+
7
+ <details disabled>
8
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
9
+ No other changes yet.
10
+ </details>
11
+
12
+ ```grain
13
+ import Pervasives from "pervasives"
14
+ ```
15
+
16
+ ## Types
17
+
18
+ Type declarations included in the Pervasives module.
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.
57
+
58
+ ### Pervasives.**(!)**
59
+
60
+ <details disabled>
61
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
62
+ No other changes yet.
63
+ </details>
64
+
65
+ ```grain
66
+ (!) : Bool -> Bool
67
+ ```
68
+
69
+ Computes the logical NOT (`!`) of the given operand.
70
+ Inverts the given Boolean value.
71
+
72
+ Parameters:
73
+
74
+ |param|type|description|
75
+ |-----|----|-----------|
76
+ |`value`|`Bool`|The operand|
77
+
78
+ Returns:
79
+
80
+ |type|description|
81
+ |----|-----------|
82
+ |`Bool`|The inverted value|
83
+
84
+ Examples:
85
+
86
+ ```grain
87
+ !true // false
88
+ ```
89
+
90
+ ```grain
91
+ !false // true
92
+ ```
93
+
94
+ ### Pervasives.**(&&)**
95
+
96
+ <details disabled>
97
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
98
+ No other changes yet.
99
+ </details>
100
+
101
+ ```grain
102
+ (&&) : (Bool, Bool) -> Bool
103
+ ```
104
+
105
+ Computes the logical AND (`&&`) of the given operands.
106
+
107
+ If the first operand is `false`, returns `false` without evaluating the second operand.
108
+ If the first operand is `true`, returns the value of the second operand.
109
+
110
+ Parameters:
111
+
112
+ |param|type|description|
113
+ |-----|----|-----------|
114
+ |`value1`|`Bool`|The first operand|
115
+ |`value2`|`Bool`|The second operand|
116
+
117
+ Returns:
118
+
119
+ |type|description|
120
+ |----|-----------|
121
+ |`Bool`|The first operand if it is `false` or the value of the second operand otherwise|
122
+
123
+ ### Pervasives.**(||)**
124
+
125
+ <details disabled>
126
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
127
+ No other changes yet.
128
+ </details>
129
+
130
+ ```grain
131
+ (||) : (Bool, Bool) -> Bool
132
+ ```
133
+
134
+ Computes the logical OR `||` of the given operands.
135
+
136
+ If the first operand is `true`, returns `true` without evaluating the second operand.
137
+ If the first operand is `false`, returns the value of the second operand.
138
+
139
+ Parameters:
140
+
141
+ |param|type|description|
142
+ |-----|----|-----------|
143
+ |`value1`|`Bool`|The first operand|
144
+ |`value2`|`Bool`|The second operand|
145
+
146
+ Returns:
147
+
148
+ |type|description|
149
+ |----|-----------|
150
+ |`Bool`|The first operand if it is `true` or the value of the second operand otherwise|
151
+
152
+ ## Comparison operations
153
+
154
+ Infix functions for comparing values.
155
+
156
+ ### Pervasives.**(==)**
157
+
158
+ <details disabled>
159
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
160
+ No other changes yet.
161
+ </details>
162
+
163
+ ```grain
164
+ (==) : (a, a) -> Bool
165
+ ```
166
+
167
+ Check that two values are equal. This checks for structural equality,
168
+ so it also works for comparing things like tuples and lists.
169
+
170
+ Parameters:
171
+
172
+ |param|type|description|
173
+ |-----|----|-----------|
174
+ |`value1`|`a`|The first operand|
175
+ |`value2`|`a`|The second operand|
176
+
177
+ Returns:
178
+
179
+ |type|description|
180
+ |----|-----------|
181
+ |`Bool`|`true` if the values are structurally equal or `false` otherwise|
182
+
183
+ ### Pervasives.**(!=)**
184
+
185
+ <details disabled>
186
+ <summary tabindex="-1">Added in <code>0.2.0</code></summary>
187
+ No other changes yet.
188
+ </details>
189
+
190
+ ```grain
191
+ (!=) : (a, a) -> Bool
192
+ ```
193
+
194
+ Check that two values are **not** equal. This checks for structural equality,
195
+ so it also works for comparing things like tuples and lists.
196
+
197
+ Parameters:
198
+
199
+ |param|type|description|
200
+ |-----|----|-----------|
201
+ |`value1`|`a`|The first operand|
202
+ |`value2`|`a`|The second operand|
203
+
204
+ Returns:
205
+
206
+ |type|description|
207
+ |----|-----------|
208
+ |`Bool`|`false` if the values are structurally equal or `true` otherwise|
209
+
210
+ ### Pervasives.**is**
211
+
212
+ <details disabled>
213
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
214
+ No other changes yet.
215
+ </details>
216
+
217
+ ```grain
218
+ is : (a, a) -> Bool
219
+ ```
220
+
221
+ Checks that two values are physically equal.
222
+ Use this operator if you don’t need or want structural equality.
223
+
224
+ Parameters:
225
+
226
+ |param|type|description|
227
+ |-----|----|-----------|
228
+ |`value1`|`a`|The first operand|
229
+ |`value2`|`a`|The second operand|
230
+
231
+ Returns:
232
+
233
+ |type|description|
234
+ |----|-----------|
235
+ |`Bool`|`true` if the values are physically equal or `false` otherwise|
236
+
237
+ ### Pervasives.**isnt**
238
+
239
+ <details disabled>
240
+ <summary tabindex="-1">Added in <code>0.2.0</code></summary>
241
+ No other changes yet.
242
+ </details>
243
+
244
+ ```grain
245
+ isnt : (a, a) -> Bool
246
+ ```
247
+
248
+ Checks that two values are **not** physically equal.
249
+ Use this operator if you don’t need or want structural equality.
250
+
251
+ Parameters:
252
+
253
+ |param|type|description|
254
+ |-----|----|-----------|
255
+ |`value1`|`a`|The first operand|
256
+ |`value2`|`a`|The second operand|
257
+
258
+ Returns:
259
+
260
+ |type|description|
261
+ |----|-----------|
262
+ |`Bool`|`false` if the values are physically equal or `true` otherwise|
263
+
264
+ ## Number comparisons
265
+
266
+ Infix functions for comparing Number values.
267
+
268
+ ### Pervasives.**(<)**
269
+
270
+ <details disabled>
271
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
272
+ No other changes yet.
273
+ </details>
274
+
275
+ ```grain
276
+ (<) : (Number, Number) -> Bool
277
+ ```
278
+
279
+ Checks if the first operand is less than the second operand.
280
+
281
+ Parameters:
282
+
283
+ |param|type|description|
284
+ |-----|----|-----------|
285
+ |`num1`|`Number`|The first operand|
286
+ |`num2`|`Number`|The second operand|
287
+
288
+ Returns:
289
+
290
+ |type|description|
291
+ |----|-----------|
292
+ |`Bool`|`true` if the first operand is less than the second operand or `false` otherwise|
293
+
294
+ ### Pervasives.**(>)**
295
+
296
+ <details disabled>
297
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
298
+ No other changes yet.
299
+ </details>
300
+
301
+ ```grain
302
+ (>) : (Number, Number) -> Bool
303
+ ```
304
+
305
+ Checks if the first operand is greater than the second operand.
306
+
307
+ Parameters:
308
+
309
+ |param|type|description|
310
+ |-----|----|-----------|
311
+ |`num1`|`Number`|The first operand|
312
+ |`num2`|`Number`|The second operand|
313
+
314
+ Returns:
315
+
316
+ |type|description|
317
+ |----|-----------|
318
+ |`Bool`|`true` if the first operand is greater than the second operand or `false` otherwise|
319
+
320
+ ### Pervasives.**(<=)**
321
+
322
+ <details disabled>
323
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
324
+ No other changes yet.
325
+ </details>
326
+
327
+ ```grain
328
+ (<=) : (Number, Number) -> Bool
329
+ ```
330
+
331
+ Checks if the first operand is less than or equal to the second operand.
332
+
333
+ Parameters:
334
+
335
+ |param|type|description|
336
+ |-----|----|-----------|
337
+ |`num1`|`Number`|The first operand|
338
+ |`num2`|`Number`|The second operand|
339
+
340
+ Returns:
341
+
342
+ |type|description|
343
+ |----|-----------|
344
+ |`Bool`|`true` if the first operand is less than or equal to the second operand or `false` otherwise|
345
+
346
+ ### Pervasives.**(>=)**
347
+
348
+ <details disabled>
349
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
350
+ No other changes yet.
351
+ </details>
352
+
353
+ ```grain
354
+ (>=) : (Number, Number) -> Bool
355
+ ```
356
+
357
+ Checks if the first operand is greater than or equal to the second operand.
358
+
359
+ Parameters:
360
+
361
+ |param|type|description|
362
+ |-----|----|-----------|
363
+ |`num1`|`Number`|The first operand|
364
+ |`num2`|`Number`|The second operand|
365
+
366
+ Returns:
367
+
368
+ |type|description|
369
+ |----|-----------|
370
+ |`Bool`|`true` if the first operand is greater than or equal to the second operand or `false` otherwise|
371
+
372
+ ## Math operations
373
+
374
+ Infix functions for working with Number values.
375
+
376
+ ### Pervasives.**(+)**
377
+
378
+ <details disabled>
379
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
380
+ No other changes yet.
381
+ </details>
382
+
383
+ ```grain
384
+ (+) : (Number, Number) -> Number
385
+ ```
386
+
387
+ Computes the sum of its operands.
388
+
389
+ Parameters:
390
+
391
+ |param|type|description|
392
+ |-----|----|-----------|
393
+ |`num1`|`Number`|The first operand|
394
+ |`num2`|`Number`|The second operand|
395
+
396
+ Returns:
397
+
398
+ |type|description|
399
+ |----|-----------|
400
+ |`Number`|The sum of the two operands|
401
+
402
+ ### Pervasives.**(-)**
403
+
404
+ <details disabled>
405
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
406
+ No other changes yet.
407
+ </details>
408
+
409
+ ```grain
410
+ (-) : (Number, Number) -> Number
411
+ ```
412
+
413
+ Computes the difference of its operands.
414
+
415
+ Parameters:
416
+
417
+ |param|type|description|
418
+ |-----|----|-----------|
419
+ |`num1`|`Number`|The first operand|
420
+ |`num2`|`Number`|The second operand|
421
+
422
+ Returns:
423
+
424
+ |type|description|
425
+ |----|-----------|
426
+ |`Number`|The difference of the two operands|
427
+
428
+ ### Pervasives.**(*)**
429
+
430
+ <details disabled>
431
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
432
+ No other changes yet.
433
+ </details>
434
+
435
+ ```grain
436
+ (*) : (Number, Number) -> Number
437
+ ```
438
+
439
+ Computes the product of its operands.
440
+
441
+ Parameters:
442
+
443
+ |param|type|description|
444
+ |-----|----|-----------|
445
+ |`num1`|`Number`|The first operand|
446
+ |`num2`|`Number`|The second operand|
447
+
448
+ Returns:
449
+
450
+ |type|description|
451
+ |----|-----------|
452
+ |`Number`|The product of the two operands|
453
+
454
+ ### Pervasives.**(/)**
455
+
456
+ <details disabled>
457
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
458
+ No other changes yet.
459
+ </details>
460
+
461
+ ```grain
462
+ (/) : (Number, Number) -> Number
463
+ ```
464
+
465
+ Computes the quotient of its operands.
466
+
467
+ Parameters:
468
+
469
+ |param|type|description|
470
+ |-----|----|-----------|
471
+ |`num1`|`Number`|The first operand|
472
+ |`num2`|`Number`|The second operand|
473
+
474
+ Returns:
475
+
476
+ |type|description|
477
+ |----|-----------|
478
+ |`Number`|The quotient of the two operands|
479
+
480
+ ### Pervasives.**(%)**
481
+
482
+ <details disabled>
483
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
484
+ No other changes yet.
485
+ </details>
486
+
487
+ ```grain
488
+ (%) : (Number, Number) -> Number
489
+ ```
490
+
491
+ Computes the remainder of the division of the first operand by the second.
492
+ The result will have the sign of the second operand.
493
+
494
+ Parameters:
495
+
496
+ |param|type|description|
497
+ |-----|----|-----------|
498
+ |`num1`|`Number`|The first operand|
499
+ |`num2`|`Number`|The second operand|
500
+
501
+ Returns:
502
+
503
+ |type|description|
504
+ |----|-----------|
505
+ |`Number`|The modulus of its operands|
506
+
507
+ ### Pervasives.**incr**
508
+
509
+ <details disabled>
510
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
511
+ No other changes yet.
512
+ </details>
513
+
514
+ ```grain
515
+ incr : Number -> Number
516
+ ```
517
+
518
+ Increments the value by one.
519
+
520
+ Parameters:
521
+
522
+ |param|type|description|
523
+ |-----|----|-----------|
524
+ |`value`|`Number`|The value to increment|
525
+
526
+ Returns:
527
+
528
+ |type|description|
529
+ |----|-----------|
530
+ |`Number`|The incremented value|
531
+
532
+ ### Pervasives.**decr**
533
+
534
+ <details disabled>
535
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
536
+ No other changes yet.
537
+ </details>
538
+
539
+ ```grain
540
+ decr : Number -> Number
541
+ ```
542
+
543
+ Decrements the value by one.
544
+
545
+ Parameters:
546
+
547
+ |param|type|description|
548
+ |-----|----|-----------|
549
+ |`value`|`Number`|The value to decrement|
550
+
551
+ Returns:
552
+
553
+ |type|description|
554
+ |----|-----------|
555
+ |`Number`|The decremented value|
556
+
557
+ ## String operations
558
+
559
+ Infix functions for operating on String values.
560
+
561
+ ### Pervasives.**(++)**
562
+
563
+ <details disabled>
564
+ <summary tabindex="-1">Added in <code>0.2.0</code></summary>
565
+ No other changes yet.
566
+ </details>
567
+
568
+ ```grain
569
+ (++) : (String, String) -> String
570
+ ```
571
+
572
+ Concatenate two strings.
573
+
574
+ Parameters:
575
+
576
+ |param|type|description|
577
+ |-----|----|-----------|
578
+ |`str1`|`String`|The beginning string|
579
+ |`str2`|`String`|The ending string|
580
+
581
+ Returns:
582
+
583
+ |type|description|
584
+ |----|-----------|
585
+ |`String`|The combined string|
586
+
587
+ Examples:
588
+
589
+ ```grain
590
+ "Foo" ++ "Bar" == "FooBar"
591
+ ```
592
+
593
+ ## Bitwise operations
594
+
595
+ Infix functions for operating on bits of Number values.
596
+
597
+ ### Pervasives.**lnot**
598
+
599
+ <details disabled>
600
+ <summary tabindex="-1">Added in <code>0.2.0</code></summary>
601
+ No other changes yet.
602
+ </details>
603
+
604
+ ```grain
605
+ lnot : Number -> Number
606
+ ```
607
+
608
+ Computes the bitwise NOT of the operand.
609
+
610
+ Parameters:
611
+
612
+ |param|type|description|
613
+ |-----|----|-----------|
614
+ |`value`|`Number`|The operand|
615
+
616
+ Returns:
617
+
618
+ |type|description|
619
+ |----|-----------|
620
+ |`Number`|Containing the inverted bits of the operand|
621
+
622
+ ### Pervasives.**(&)**
623
+
624
+ <details>
625
+ <summary>Added in <code>0.3.0</code></summary>
626
+ <table>
627
+ <thead>
628
+ <tr><th>version</th><th>changes</th></tr>
629
+ </thead>
630
+ <tbody>
631
+ <tr><td><code>0.2.0</code></td><td>Originally named `land`</td></tr>
632
+ <tr><td><code>0.3.0</code></td><td>Renamed to `&`</td></tr>
633
+ </tbody>
634
+ </table>
635
+ </details>
636
+
637
+ ```grain
638
+ (&) : (Number, Number) -> Number
639
+ ```
640
+
641
+ Computes the bitwise AND (`&`) on the given operands.
642
+
643
+ Parameters:
644
+
645
+ |param|type|description|
646
+ |-----|----|-----------|
647
+ |`value1`|`Number`|The first operand|
648
+ |`value2`|`Number`|The second operand|
649
+
650
+ Returns:
651
+
652
+ |type|description|
653
+ |----|-----------|
654
+ |`Number`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
655
+
656
+ ### Pervasives.**(|)**
657
+
658
+ <details>
659
+ <summary>Added in <code>0.3.0</code></summary>
660
+ <table>
661
+ <thead>
662
+ <tr><th>version</th><th>changes</th></tr>
663
+ </thead>
664
+ <tbody>
665
+ <tr><td><code>0.2.0</code></td><td>Originally named `lor`</td></tr>
666
+ <tr><td><code>0.3.0</code></td><td>Renamed to `|`</td></tr>
667
+ </tbody>
668
+ </table>
669
+ </details>
670
+
671
+ ```grain
672
+ (|) : (Number, Number) -> Number
673
+ ```
674
+
675
+ Computes the bitwise OR (`|`) on the given operands.
676
+
677
+ Parameters:
678
+
679
+ |param|type|description|
680
+ |-----|----|-----------|
681
+ |`value1`|`Number`|The first operand|
682
+ |`value2`|`Number`|The second operand|
683
+
684
+ Returns:
685
+
686
+ |type|description|
687
+ |----|-----------|
688
+ |`Number`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
689
+
690
+ ### Pervasives.**(^)**
691
+
692
+ <details>
693
+ <summary>Added in <code>0.3.0</code></summary>
694
+ <table>
695
+ <thead>
696
+ <tr><th>version</th><th>changes</th></tr>
697
+ </thead>
698
+ <tbody>
699
+ <tr><td><code>0.1.0</code></td><td>The `^` operator was originally an alias of `unbox`</td></tr>
700
+ <tr><td><code>0.2.0</code></td><td>Originally named `lxor`</td></tr>
701
+ <tr><td><code>0.3.0</code></td><td>Renamed to `^`</td></tr>
702
+ </tbody>
703
+ </table>
704
+ </details>
705
+
706
+ ```grain
707
+ (^) : (Number, Number) -> Number
708
+ ```
709
+
710
+ Computes the bitwise XOR (`^`) on the given operands.
711
+
712
+ Parameters:
713
+
714
+ |param|type|description|
715
+ |-----|----|-----------|
716
+ |`value1`|`Number`|The first operand|
717
+ |`value2`|`Number`|The second operand|
718
+
719
+ Returns:
720
+
721
+ |type|description|
722
+ |----|-----------|
723
+ |`Number`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
724
+
725
+ ### Pervasives.**(<<)**
726
+
727
+ <details>
728
+ <summary>Added in <code>0.3.0</code></summary>
729
+ <table>
730
+ <thead>
731
+ <tr><th>version</th><th>changes</th></tr>
732
+ </thead>
733
+ <tbody>
734
+ <tr><td><code>0.2.0</code></td><td>Originally named `lsl`</td></tr>
735
+ <tr><td><code>0.3.0</code></td><td>Renamed to `<<`</td></tr>
736
+ </tbody>
737
+ </table>
738
+ </details>
739
+
740
+ ```grain
741
+ (<<) : (Number, Number) -> Number
742
+ ```
743
+
744
+ Shifts the bits of the value left by the given number of bits.
745
+
746
+ Parameters:
747
+
748
+ |param|type|description|
749
+ |-----|----|-----------|
750
+ |`value`|`Number`|The value to shift|
751
+ |`amount`|`Number`|The number of bits to shift by|
752
+
753
+ Returns:
754
+
755
+ |type|description|
756
+ |----|-----------|
757
+ |`Number`|The shifted value|
758
+
759
+ ### Pervasives.**(>>>)**
760
+
761
+ <details>
762
+ <summary>Added in <code>0.3.0</code></summary>
763
+ <table>
764
+ <thead>
765
+ <tr><th>version</th><th>changes</th></tr>
766
+ </thead>
767
+ <tbody>
768
+ <tr><td><code>0.2.0</code></td><td>Originally named `lsr`</td></tr>
769
+ <tr><td><code>0.3.0</code></td><td>Renamed to `>>>`</td></tr>
770
+ </tbody>
771
+ </table>
772
+ </details>
773
+
774
+ ```grain
775
+ (>>>) : (Number, Number) -> Number
776
+ ```
777
+
778
+ Shifts the bits of the value right by the given number of bits, preserving the sign bit.
779
+
780
+ Parameters:
781
+
782
+ |param|type|description|
783
+ |-----|----|-----------|
784
+ |`value`|`Number`|The value to shift|
785
+ |`amount`|`Number`|The amount to shift by|
786
+
787
+ Returns:
788
+
789
+ |type|description|
790
+ |----|-----------|
791
+ |`Number`|The shifted value|
792
+
793
+ ### Pervasives.**(>>)**
794
+
795
+ <details>
796
+ <summary>Added in <code>0.3.0</code></summary>
797
+ <table>
798
+ <thead>
799
+ <tr><th>version</th><th>changes</th></tr>
800
+ </thead>
801
+ <tbody>
802
+ <tr><td><code>0.2.0</code></td><td>Originally named `asr`</td></tr>
803
+ <tr><td><code>0.3.0</code></td><td>Renamed to `>>`</td></tr>
804
+ </tbody>
805
+ </table>
806
+ </details>
807
+
808
+ ```grain
809
+ (>>) : (Number, Number) -> Number
810
+ ```
811
+
812
+ Shifts the bits of the value right by the given number of bits.
813
+
814
+ Parameters:
815
+
816
+ |param|type|description|
817
+ |-----|----|-----------|
818
+ |`value`|`Number`|The value to shift|
819
+ |`amount`|`Number`|The amount to shift by|
820
+
821
+ Returns:
822
+
823
+ |type|description|
824
+ |----|-----------|
825
+ |`Number`|The shifted value|
826
+
827
+ ## Printing
828
+
829
+ Functions that deal with printing.
830
+
831
+ ### Pervasives.**toString**
832
+
833
+ <details disabled>
834
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
835
+ No other changes yet.
836
+ </details>
837
+
838
+ ```grain
839
+ toString : a -> String
840
+ ```
841
+
842
+ Converts the given operand to a string.
843
+ Provides a better representation of data types if those types are exported from the module.
844
+
845
+ Parameters:
846
+
847
+ |param|type|description|
848
+ |-----|----|-----------|
849
+ |`value`|`a`|The operand|
850
+
851
+ Returns:
852
+
853
+ |type|description|
854
+ |----|-----------|
855
+ |`String`|The operand, as a string|
856
+
857
+ ### Pervasives.**print**
858
+
859
+ <details disabled>
860
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
861
+ No other changes yet.
862
+ </details>
863
+
864
+ ```grain
865
+ print : a -> Void
866
+ ```
867
+
868
+ Prints the given operand to the console. Works for any type. Internally, calls `toString`
869
+ on the operand, so a better representation of data type will be printed if those types
870
+ are exported from the module.
871
+
872
+ Parameters:
873
+
874
+ |param|type|description|
875
+ |-----|----|-----------|
876
+ |`value`|`a`|The operand|
877
+
878
+ ## Type helpers
879
+
880
+ Functions that help with typechecking.
881
+
882
+ ### Pervasives.**ignore**
883
+
884
+ <details disabled>
885
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
886
+ No other changes yet.
887
+ </details>
888
+
889
+ ```grain
890
+ ignore : a -> Void
891
+ ```
892
+
893
+ Accepts any value and always returns `void`.
894
+
895
+ Parameters:
896
+
897
+ |param|type|description|
898
+ |-----|----|-----------|
899
+ |`value`|`a`|The value to ignore|
900
+
901
+ ## Assertions
902
+
903
+ Functions that raise if conditions are not met.
904
+
905
+ ### Pervasives.**assert**
906
+
907
+ <details disabled>
908
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
909
+ No other changes yet.
910
+ </details>
911
+
912
+ ```grain
913
+ assert : Bool -> Void
914
+ ```
915
+
916
+ Assert that the given Boolean condition is `true`.
917
+ Throws an `AssertionError` if the condition is `false`.
918
+
919
+ Parameters:
920
+
921
+ |param|type|description|
922
+ |-----|----|-----------|
923
+ |`condition`|`Bool`|The condition to assert|
924
+
925
+ Examples:
926
+
927
+ ```grain
928
+ assert 3 > 2
929
+ ```
930
+
931
+ ```grain
932
+ assert true
933
+ ```
934
+
935
+ ## Failures
936
+
937
+ Functions that throw an Exception unconditionally.
938
+
939
+ ### Pervasives.**throw**
940
+
941
+ <details disabled>
942
+ <summary tabindex="-1">Added in <code>0.3.0</code></summary>
943
+ No other changes yet.
944
+ </details>
945
+
946
+ ```grain
947
+ throw : Exception -> a
948
+ ```
949
+
950
+ Throw an exception. Currently, exceptions cannot be caught and will crash your program.
951
+
952
+ Parameters:
953
+
954
+ |param|type|description|
955
+ |-----|----|-----------|
956
+ |`exception`|`Exception`|The exception to be thrown|
957
+
958
+ Returns:
959
+
960
+ |type|description|
961
+ |----|-----------|
962
+ |`a`|Anything and nothing—your program won't continue past a throw|
963
+
964
+ ### Pervasives.**fail**
965
+
966
+ ```grain
967
+ fail : String -> a
968
+ ```
969
+
970
+ Unconditionally throw a `Failure` exception with a message.
971
+ Currently, Exceptions cannot be caught and will crash your program.
972
+
973
+ Parameters:
974
+
975
+ |param|type|description|
976
+ |-----|----|-----------|
977
+ |`message`|`String`|The reason for the failure|
978
+
979
+ Returns:
980
+
981
+ |type|description|
982
+ |----|-----------|
983
+ |`a`|Anything and nothing—your program won't continue past a fail expression|
984
+
985
+ ## Other
986
+
987
+ Other functions on values.
988
+
989
+ ### Pervasives.**identity**
990
+
991
+ <details disabled>
992
+ <summary tabindex="-1">Added in <code>0.2.0</code></summary>
993
+ No other changes yet.
994
+ </details>
995
+
996
+ ```grain
997
+ identity : a -> a
998
+ ```
999
+
1000
+ Provides the operand untouched.
1001
+
1002
+ Parameters:
1003
+
1004
+ |param|type|description|
1005
+ |-----|----|-----------|
1006
+ |`value`|`a`|The value to return|
1007
+
1008
+ Returns:
1009
+
1010
+ |type|description|
1011
+ |----|-----------|
1012
+ |`a`|The value untouched|
1013
+
1014
+ ## Box operations
1015
+
1016
+ Functions for working with Box values.
1017
+
1018
+ ### Pervasives.**box**
1019
+
1020
+ <details disabled>
1021
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
1022
+ No other changes yet.
1023
+ </details>
1024
+
1025
+ ```grain
1026
+ box : a -> Box<a>
1027
+ ```
1028
+
1029
+ Creates a box containing the given initial value.
1030
+ Values inside a box can be swapped out with the `:=` operator.
1031
+ Generally, `let mut` expressions are preferable to using a Box.
1032
+
1033
+ Parameters:
1034
+
1035
+ |param|type|description|
1036
+ |-----|----|-----------|
1037
+ |`initial`|`a`|The initial value inside the box|
1038
+
1039
+ Returns:
1040
+
1041
+ |type|description|
1042
+ |----|-----------|
1043
+ |`Box<a>`|The box containing the initial value|
1044
+
1045
+ ### Pervasives.**unbox**
1046
+
1047
+ <details disabled>
1048
+ <summary tabindex="-1">Added in <code>0.1.0</code></summary>
1049
+ No other changes yet.
1050
+ </details>
1051
+
1052
+ ```grain
1053
+ unbox : Box<a> -> a
1054
+ ```
1055
+
1056
+ Retrieves the current value from a box.
1057
+
1058
+ Parameters:
1059
+
1060
+ |param|type|description|
1061
+ |-----|----|-----------|
1062
+ |`box`|`Box<a>`|The box to unwrap|
1063
+
1064
+ Returns:
1065
+
1066
+ |type|description|
1067
+ |----|-----------|
1068
+ |`a`|The value inside the box|
1069
+
1070
+ ## List operations
1071
+
1072
+ Functions for working with List values.
1073
+
1074
+ ### Pervasives.**cons**
1075
+
1076
+ > **Deprecated:** This will be removed in a future release of Grain.
1077
+
1078
+ <details disabled>
1079
+ <summary tabindex="-1">Added in <code>0.4.0</code></summary>
1080
+ No other changes yet.
1081
+ </details>
1082
+
1083
+ ```grain
1084
+ cons : (a, List<a>) -> List<a>
1085
+ ```
1086
+
1087
+ The list spread syntax (`[a, ...b]`) provided as a function.
1088
+
1089
+ Parameters:
1090
+
1091
+ |param|type|description|
1092
+ |-----|----|-----------|
1093
+ |`a`|`a`|The head of the list|
1094
+ |`b`|`List<a>`|The tail of the list|
1095
+
1096
+ Returns:
1097
+
1098
+ |type|description|
1099
+ |----|-----------|
1100
+ |`List<a>`|The new list|
1101
+
1102
+ ### Pervasives.**empty**
1103
+
1104
+ > **Deprecated:** This will be removed in a future release of Grain.
1105
+
1106
+ <details disabled>
1107
+ <summary tabindex="-1">Added in <code>0.4.0</code></summary>
1108
+ No other changes yet.
1109
+ </details>
1110
+
1111
+ ```grain
1112
+ empty : List<a>
1113
+ ```
1114
+
1115
+ The empty list syntax (`[]`) provided as a value.
1116
+