@grain/stdlib 0.6.4 → 0.6.5
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 +14 -0
- package/array.gr +2 -0
- package/bytes.gr +38 -7
- package/float32.gr +68 -0
- package/float32.md +164 -0
- package/float64.gr +87 -16
- package/float64.md +164 -0
- package/hash.gr +2 -0
- package/int32.gr +107 -0
- package/int32.md +235 -0
- package/int64.gr +107 -0
- package/int64.md +235 -0
- package/map.gr +3 -2
- package/package.json +1 -1
- package/pervasives.md +10 -3
- package/runtime/numbers.gr +181 -100
- package/runtime/string.gr +1 -0
- package/runtime/string.md +10 -3
- package/string.gr +291 -72
- package/string.md +108 -0
- package/wasi/file.gr +5 -0
package/int64.md
CHANGED
|
@@ -13,6 +13,14 @@ No other changes yet.
|
|
|
13
13
|
from "int64" include Int64
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
+
```grain
|
|
17
|
+
1L
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```grain
|
|
21
|
+
-1L
|
|
22
|
+
```
|
|
23
|
+
|
|
16
24
|
## Values
|
|
17
25
|
|
|
18
26
|
Functions and constants included in the Int64 module.
|
|
@@ -92,6 +100,12 @@ Returns:
|
|
|
92
100
|
|----|-----------|
|
|
93
101
|
|`Int64`|The Uint64 represented as an Int64|
|
|
94
102
|
|
|
103
|
+
Examples:
|
|
104
|
+
|
|
105
|
+
```grain
|
|
106
|
+
Int64.fromUint64(1uL) == 1L
|
|
107
|
+
```
|
|
108
|
+
|
|
95
109
|
### Int64.**incr**
|
|
96
110
|
|
|
97
111
|
<details disabled>
|
|
@@ -117,6 +131,16 @@ Returns:
|
|
|
117
131
|
|----|-----------|
|
|
118
132
|
|`Int64`|The incremented value|
|
|
119
133
|
|
|
134
|
+
Examples:
|
|
135
|
+
|
|
136
|
+
```grain
|
|
137
|
+
Int64.incr(1L) == 2L
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
```grain
|
|
141
|
+
Int64.incr(-2L) == -1L
|
|
142
|
+
```
|
|
143
|
+
|
|
120
144
|
### Int64.**decr**
|
|
121
145
|
|
|
122
146
|
<details disabled>
|
|
@@ -142,6 +166,16 @@ Returns:
|
|
|
142
166
|
|----|-----------|
|
|
143
167
|
|`Int64`|The decremented value|
|
|
144
168
|
|
|
169
|
+
Examples:
|
|
170
|
+
|
|
171
|
+
```grain
|
|
172
|
+
Int64.decr(2L) == 1L
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```grain
|
|
176
|
+
Int64.decr(0L) == -1L
|
|
177
|
+
```
|
|
178
|
+
|
|
145
179
|
### Int64.**(+)**
|
|
146
180
|
|
|
147
181
|
<details>
|
|
@@ -175,6 +209,13 @@ Returns:
|
|
|
175
209
|
|----|-----------|
|
|
176
210
|
|`Int64`|The sum of the two operands|
|
|
177
211
|
|
|
212
|
+
Examples:
|
|
213
|
+
|
|
214
|
+
```grain
|
|
215
|
+
use Int64.{ (+) }
|
|
216
|
+
assert 1L + 1L == 2L
|
|
217
|
+
```
|
|
218
|
+
|
|
178
219
|
### Int64.**(-)**
|
|
179
220
|
|
|
180
221
|
<details>
|
|
@@ -208,6 +249,13 @@ Returns:
|
|
|
208
249
|
|----|-----------|
|
|
209
250
|
|`Int64`|The difference of the two operands|
|
|
210
251
|
|
|
252
|
+
Examples:
|
|
253
|
+
|
|
254
|
+
```grain
|
|
255
|
+
use Int64.{ (-) }
|
|
256
|
+
assert 2L - 1L == 1L
|
|
257
|
+
```
|
|
258
|
+
|
|
211
259
|
### Int64.**(*)**
|
|
212
260
|
|
|
213
261
|
<details>
|
|
@@ -241,6 +289,13 @@ Returns:
|
|
|
241
289
|
|----|-----------|
|
|
242
290
|
|`Int64`|The product of the two operands|
|
|
243
291
|
|
|
292
|
+
Examples:
|
|
293
|
+
|
|
294
|
+
```grain
|
|
295
|
+
use Int64.{ (*) }
|
|
296
|
+
assert 2L * 2L == 4L
|
|
297
|
+
```
|
|
298
|
+
|
|
244
299
|
### Int64.**(/)**
|
|
245
300
|
|
|
246
301
|
<details>
|
|
@@ -274,6 +329,13 @@ Returns:
|
|
|
274
329
|
|----|-----------|
|
|
275
330
|
|`Int64`|The quotient of its operands|
|
|
276
331
|
|
|
332
|
+
Examples:
|
|
333
|
+
|
|
334
|
+
```grain
|
|
335
|
+
use Int64.{ (/) }
|
|
336
|
+
assert 8L / 2L == 4L
|
|
337
|
+
```
|
|
338
|
+
|
|
277
339
|
### Int64.**rem**
|
|
278
340
|
|
|
279
341
|
<details disabled>
|
|
@@ -300,6 +362,12 @@ Returns:
|
|
|
300
362
|
|----|-----------|
|
|
301
363
|
|`Int64`|The remainder of its operands|
|
|
302
364
|
|
|
365
|
+
Examples:
|
|
366
|
+
|
|
367
|
+
```grain
|
|
368
|
+
Int64.rem(8L, 3L) == 2L
|
|
369
|
+
```
|
|
370
|
+
|
|
303
371
|
### Int64.**(%)**
|
|
304
372
|
|
|
305
373
|
<details>
|
|
@@ -340,6 +408,13 @@ Throws:
|
|
|
340
408
|
|
|
341
409
|
* When `y` is zero
|
|
342
410
|
|
|
411
|
+
Examples:
|
|
412
|
+
|
|
413
|
+
```grain
|
|
414
|
+
use Int64.{ (%) }
|
|
415
|
+
assert -5L % 3L == 1L
|
|
416
|
+
```
|
|
417
|
+
|
|
343
418
|
### Int64.**rotl**
|
|
344
419
|
|
|
345
420
|
<details disabled>
|
|
@@ -366,6 +441,16 @@ Returns:
|
|
|
366
441
|
|----|-----------|
|
|
367
442
|
|`Int64`|The rotated value|
|
|
368
443
|
|
|
444
|
+
Examples:
|
|
445
|
+
|
|
446
|
+
```grain
|
|
447
|
+
Int64.rotl(1L, 1L) == 2L
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
```grain
|
|
451
|
+
Int64.rotl(1L, 2L) == 4L
|
|
452
|
+
```
|
|
453
|
+
|
|
369
454
|
### Int64.**rotr**
|
|
370
455
|
|
|
371
456
|
<details disabled>
|
|
@@ -392,6 +477,16 @@ Returns:
|
|
|
392
477
|
|----|-----------|
|
|
393
478
|
|`Int64`|The rotated value|
|
|
394
479
|
|
|
480
|
+
Examples:
|
|
481
|
+
|
|
482
|
+
```grain
|
|
483
|
+
Int64.rotr(2L, 1L) == 1L
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
```grain
|
|
487
|
+
Int64.rotr(4L, 2L) == 1L
|
|
488
|
+
```
|
|
489
|
+
|
|
395
490
|
### Int64.**(<<)**
|
|
396
491
|
|
|
397
492
|
<details>
|
|
@@ -425,6 +520,13 @@ Returns:
|
|
|
425
520
|
|----|-----------|
|
|
426
521
|
|`Int64`|The shifted value|
|
|
427
522
|
|
|
523
|
+
Examples:
|
|
524
|
+
|
|
525
|
+
```grain
|
|
526
|
+
use Int64.{ (<<) }
|
|
527
|
+
assert (5L << 1L) == 10L
|
|
528
|
+
```
|
|
529
|
+
|
|
428
530
|
### Int64.**(>>)**
|
|
429
531
|
|
|
430
532
|
<details>
|
|
@@ -458,6 +560,13 @@ Returns:
|
|
|
458
560
|
|----|-----------|
|
|
459
561
|
|`Int64`|The shifted value|
|
|
460
562
|
|
|
563
|
+
Examples:
|
|
564
|
+
|
|
565
|
+
```grain
|
|
566
|
+
use Int64.{ (>>) }
|
|
567
|
+
assert (5L >> 1L) == 2L
|
|
568
|
+
```
|
|
569
|
+
|
|
461
570
|
### Int64.**(==)**
|
|
462
571
|
|
|
463
572
|
<details>
|
|
@@ -491,6 +600,13 @@ Returns:
|
|
|
491
600
|
|----|-----------|
|
|
492
601
|
|`Bool`|`true` if the first value is equal to the second value or `false` otherwise|
|
|
493
602
|
|
|
603
|
+
Examples:
|
|
604
|
+
|
|
605
|
+
```grain
|
|
606
|
+
use Int64.{ (==) }
|
|
607
|
+
assert 1L == 1L
|
|
608
|
+
```
|
|
609
|
+
|
|
494
610
|
### Int64.**(!=)**
|
|
495
611
|
|
|
496
612
|
<details>
|
|
@@ -524,6 +640,13 @@ Returns:
|
|
|
524
640
|
|----|-----------|
|
|
525
641
|
|`Bool`|`true` if the first value is not equal to the second value or `false` otherwise|
|
|
526
642
|
|
|
643
|
+
Examples:
|
|
644
|
+
|
|
645
|
+
```grain
|
|
646
|
+
use Int64.{ (!=) }
|
|
647
|
+
assert 1L != 2L
|
|
648
|
+
```
|
|
649
|
+
|
|
527
650
|
### Int64.**eqz**
|
|
528
651
|
|
|
529
652
|
<details disabled>
|
|
@@ -549,6 +672,16 @@ Returns:
|
|
|
549
672
|
|----|-----------|
|
|
550
673
|
|`Bool`|`true` if the first value is equal to zero or `false` otherwise|
|
|
551
674
|
|
|
675
|
+
Examples:
|
|
676
|
+
|
|
677
|
+
```grain
|
|
678
|
+
Int64.eqz(0L) == true
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
```grain
|
|
682
|
+
Int64.eqz(1L) == false
|
|
683
|
+
```
|
|
684
|
+
|
|
552
685
|
### Int64.**(<)**
|
|
553
686
|
|
|
554
687
|
<details>
|
|
@@ -582,6 +715,13 @@ Returns:
|
|
|
582
715
|
|----|-----------|
|
|
583
716
|
|`Bool`|`true` if the first value is less than the second value or `false` otherwise|
|
|
584
717
|
|
|
718
|
+
Examples:
|
|
719
|
+
|
|
720
|
+
```grain
|
|
721
|
+
use Int64.{ (<) }
|
|
722
|
+
assert 1L < 2L
|
|
723
|
+
```
|
|
724
|
+
|
|
585
725
|
### Int64.**(>)**
|
|
586
726
|
|
|
587
727
|
<details>
|
|
@@ -615,6 +755,13 @@ Returns:
|
|
|
615
755
|
|----|-----------|
|
|
616
756
|
|`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
|
|
617
757
|
|
|
758
|
+
Examples:
|
|
759
|
+
|
|
760
|
+
```grain
|
|
761
|
+
use Int64.{ (>) }
|
|
762
|
+
assert 2L > 1L
|
|
763
|
+
```
|
|
764
|
+
|
|
618
765
|
### Int64.**(<=)**
|
|
619
766
|
|
|
620
767
|
<details>
|
|
@@ -648,6 +795,18 @@ Returns:
|
|
|
648
795
|
|----|-----------|
|
|
649
796
|
|`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
|
|
650
797
|
|
|
798
|
+
Examples:
|
|
799
|
+
|
|
800
|
+
```grain
|
|
801
|
+
use Int64.{ (<=) }
|
|
802
|
+
assert 1L <= 2L
|
|
803
|
+
```
|
|
804
|
+
|
|
805
|
+
```grain
|
|
806
|
+
use Int64.{ (<=) }
|
|
807
|
+
assert 1L <= 1L
|
|
808
|
+
```
|
|
809
|
+
|
|
651
810
|
### Int64.**(>=)**
|
|
652
811
|
|
|
653
812
|
<details>
|
|
@@ -681,6 +840,18 @@ Returns:
|
|
|
681
840
|
|----|-----------|
|
|
682
841
|
|`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
|
|
683
842
|
|
|
843
|
+
Examples:
|
|
844
|
+
|
|
845
|
+
```grain
|
|
846
|
+
use Int64.{ (>=) }
|
|
847
|
+
assert 2L >= 1L
|
|
848
|
+
```
|
|
849
|
+
|
|
850
|
+
```grain
|
|
851
|
+
use Int64.{ (>=) }
|
|
852
|
+
assert 1L >= 1L
|
|
853
|
+
```
|
|
854
|
+
|
|
684
855
|
### Int64.**lnot**
|
|
685
856
|
|
|
686
857
|
<details disabled>
|
|
@@ -706,6 +877,12 @@ Returns:
|
|
|
706
877
|
|----|-----------|
|
|
707
878
|
|`Int64`|Containing the inverted bits of the given value|
|
|
708
879
|
|
|
880
|
+
Examples:
|
|
881
|
+
|
|
882
|
+
```grain
|
|
883
|
+
Int64.lnot(-5L) == 4L
|
|
884
|
+
```
|
|
885
|
+
|
|
709
886
|
### Int64.**(&)**
|
|
710
887
|
|
|
711
888
|
<details>
|
|
@@ -739,6 +916,13 @@ Returns:
|
|
|
739
916
|
|----|-----------|
|
|
740
917
|
|`Int64`|Containing a `1` in each bit position for which the corresponding bits of both operands are `1`|
|
|
741
918
|
|
|
919
|
+
Examples:
|
|
920
|
+
|
|
921
|
+
```grain
|
|
922
|
+
use Int64.{ (&) }
|
|
923
|
+
assert (3L & 4L) == 0L
|
|
924
|
+
```
|
|
925
|
+
|
|
742
926
|
### Int64.**(|)**
|
|
743
927
|
|
|
744
928
|
<details>
|
|
@@ -772,6 +956,13 @@ Returns:
|
|
|
772
956
|
|----|-----------|
|
|
773
957
|
|`Int64`|Containing a `1` in each bit position for which the corresponding bits of either or both operands are `1`|
|
|
774
958
|
|
|
959
|
+
Examples:
|
|
960
|
+
|
|
961
|
+
```grain
|
|
962
|
+
use Int64.{ (|) }
|
|
963
|
+
assert (3L | 4L) == 7L
|
|
964
|
+
```
|
|
965
|
+
|
|
775
966
|
### Int64.**(^)**
|
|
776
967
|
|
|
777
968
|
<details>
|
|
@@ -805,6 +996,13 @@ Returns:
|
|
|
805
996
|
|----|-----------|
|
|
806
997
|
|`Int64`|Containing a `1` in each bit position for which the corresponding bits of either but not both operands are `1`|
|
|
807
998
|
|
|
999
|
+
Examples:
|
|
1000
|
+
|
|
1001
|
+
```grain
|
|
1002
|
+
use Int64.{ (^) }
|
|
1003
|
+
assert (3L ^ 5L) == 6L
|
|
1004
|
+
```
|
|
1005
|
+
|
|
808
1006
|
### Int64.**clz**
|
|
809
1007
|
|
|
810
1008
|
<details disabled>
|
|
@@ -830,6 +1028,16 @@ Returns:
|
|
|
830
1028
|
|----|-----------|
|
|
831
1029
|
|`Int64`|The amount of leading zeros|
|
|
832
1030
|
|
|
1031
|
+
Examples:
|
|
1032
|
+
|
|
1033
|
+
```grain
|
|
1034
|
+
Int64.clz(1L) == 63L
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
```grain
|
|
1038
|
+
Int64.clz(4L) == 61L
|
|
1039
|
+
```
|
|
1040
|
+
|
|
833
1041
|
### Int64.**ctz**
|
|
834
1042
|
|
|
835
1043
|
<details disabled>
|
|
@@ -855,6 +1063,16 @@ Returns:
|
|
|
855
1063
|
|----|-----------|
|
|
856
1064
|
|`Int64`|The amount of trailing zeros|
|
|
857
1065
|
|
|
1066
|
+
Examples:
|
|
1067
|
+
|
|
1068
|
+
```grain
|
|
1069
|
+
Int64.ctz(1L) == 0L
|
|
1070
|
+
```
|
|
1071
|
+
|
|
1072
|
+
```grain
|
|
1073
|
+
Int64.ctz(4L) == 2L
|
|
1074
|
+
```
|
|
1075
|
+
|
|
858
1076
|
### Int64.**popcnt**
|
|
859
1077
|
|
|
860
1078
|
<details disabled>
|
|
@@ -880,6 +1098,16 @@ Returns:
|
|
|
880
1098
|
|----|-----------|
|
|
881
1099
|
|`Int64`|The amount of 1-bits in its operand|
|
|
882
1100
|
|
|
1101
|
+
Examples:
|
|
1102
|
+
|
|
1103
|
+
```grain
|
|
1104
|
+
Int64.popcnt(1L) == 1L
|
|
1105
|
+
```
|
|
1106
|
+
|
|
1107
|
+
```grain
|
|
1108
|
+
Int64.popcnt(3L) == 2L
|
|
1109
|
+
```
|
|
1110
|
+
|
|
883
1111
|
### Int64.**(\*\*)**
|
|
884
1112
|
|
|
885
1113
|
<details disabled>
|
|
@@ -906,3 +1134,10 @@ Returns:
|
|
|
906
1134
|
|----|-----------|
|
|
907
1135
|
|`Int64`|The base raised to the given power|
|
|
908
1136
|
|
|
1137
|
+
Examples:
|
|
1138
|
+
|
|
1139
|
+
```grain
|
|
1140
|
+
from Int64 use { (**) }
|
|
1141
|
+
assert 2L ** 3L == 8L
|
|
1142
|
+
```
|
|
1143
|
+
|
package/map.gr
CHANGED
|
@@ -436,13 +436,14 @@ provide let toArray = (map: Map<a, b>) => {
|
|
|
436
436
|
use WasmI32.{ (+) as addWasmI32 }
|
|
437
437
|
// Assign the values into the array.
|
|
438
438
|
// We store them directly to prevent GC on uninitialized array data.
|
|
439
|
-
let
|
|
439
|
+
let arrayPtr = WasmI32.fromGrain(array)
|
|
440
440
|
let item = (key, value)
|
|
441
441
|
WasmI32.store(
|
|
442
|
-
addWasmI32(
|
|
442
|
+
addWasmI32(arrayPtr, untagSimpleNumber(i) * 4n),
|
|
443
443
|
Memory.incRef(WasmI32.fromGrain(item)),
|
|
444
444
|
8n
|
|
445
445
|
)
|
|
446
|
+
ignore(array)
|
|
446
447
|
i + 1
|
|
447
448
|
}
|
|
448
449
|
reduce(reducer, 0, map)
|
package/package.json
CHANGED
package/pervasives.md
CHANGED
|
@@ -855,9 +855,16 @@ Returns:
|
|
|
855
855
|
|
|
856
856
|
### Pervasives.**print**
|
|
857
857
|
|
|
858
|
-
<details
|
|
859
|
-
<summary
|
|
860
|
-
|
|
858
|
+
<details>
|
|
859
|
+
<summary>Added in <code>0.1.0</code></summary>
|
|
860
|
+
<table>
|
|
861
|
+
<thead>
|
|
862
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
863
|
+
</thead>
|
|
864
|
+
<tbody>
|
|
865
|
+
<tr><td><code>0.6.0</code></td><td>Added support for custom suffixes</td></tr>
|
|
866
|
+
</tbody>
|
|
867
|
+
</table>
|
|
861
868
|
</details>
|
|
862
869
|
|
|
863
870
|
```grain
|