@grain/stdlib 0.6.6 → 0.7.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.
Files changed (137) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +123 -77
  6. package/bigint.md +30 -30
  7. package/buffer.gr +20 -53
  8. package/buffer.md +47 -47
  9. package/bytes.gr +111 -35
  10. package/bytes.md +111 -32
  11. package/char.gr +201 -99
  12. package/char.md +361 -34
  13. package/exception.gr +11 -11
  14. package/exception.md +26 -1
  15. package/float32.gr +327 -3
  16. package/float32.md +606 -19
  17. package/float64.gr +320 -3
  18. package/float64.md +606 -19
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +102 -14
  23. package/int16.md +23 -23
  24. package/int32.gr +25 -4
  25. package/int32.md +65 -30
  26. package/int64.gr +26 -1
  27. package/int64.md +65 -30
  28. package/int8.md +23 -23
  29. package/json.gr +366 -51
  30. package/json.md +418 -2
  31. package/list.gr +328 -31
  32. package/list.md +492 -69
  33. package/map.gr +20 -12
  34. package/map.md +44 -38
  35. package/marshal.gr +41 -40
  36. package/marshal.md +2 -2
  37. package/number.gr +159 -30
  38. package/number.md +215 -38
  39. package/option.md +21 -21
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +103 -12
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +37 -37
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +19 -19
  47. package/queue.gr +183 -29
  48. package/queue.md +296 -40
  49. package/random.md +6 -6
  50. package/range.gr +4 -4
  51. package/range.md +6 -6
  52. package/rational.md +16 -16
  53. package/regex.gr +52 -51
  54. package/regex.md +11 -11
  55. package/result.md +16 -16
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +8 -8
  59. package/runtime/atof/lemire.gr +5 -5
  60. package/runtime/atof/lemire.md +1 -1
  61. package/runtime/atof/parse.gr +16 -16
  62. package/runtime/atof/parse.md +2 -2
  63. package/runtime/atof/slow.md +1 -1
  64. package/runtime/atof/table.md +2 -2
  65. package/runtime/atoi/parse.gr +3 -3
  66. package/runtime/atoi/parse.md +1 -1
  67. package/runtime/bigint.gr +15 -47
  68. package/runtime/bigint.md +54 -60
  69. package/runtime/compare.gr +2 -2
  70. package/runtime/compare.md +1 -1
  71. package/runtime/dataStructures.md +33 -33
  72. package/runtime/debugPrint.gr +4 -1
  73. package/runtime/debugPrint.md +9 -9
  74. package/runtime/equal.gr +99 -77
  75. package/runtime/equal.md +1 -1
  76. package/runtime/exception.gr +62 -82
  77. package/runtime/exception.md +62 -11
  78. package/runtime/gc.gr +39 -45
  79. package/runtime/gc.md +4 -4
  80. package/runtime/malloc.gr +7 -7
  81. package/runtime/malloc.md +4 -4
  82. package/runtime/math/kernel/cos.gr +70 -0
  83. package/runtime/math/kernel/cos.md +14 -0
  84. package/runtime/math/kernel/sin.gr +65 -0
  85. package/runtime/math/kernel/sin.md +14 -0
  86. package/runtime/math/kernel/tan.gr +136 -0
  87. package/runtime/math/kernel/tan.md +14 -0
  88. package/runtime/math/rempio2.gr +244 -0
  89. package/runtime/math/rempio2.md +14 -0
  90. package/runtime/math/trig.gr +130 -0
  91. package/runtime/math/trig.md +28 -0
  92. package/runtime/math/umuldi.gr +26 -0
  93. package/runtime/math/umuldi.md +14 -0
  94. package/runtime/numberUtils.gr +29 -29
  95. package/runtime/numberUtils.md +12 -12
  96. package/runtime/numbers.gr +373 -381
  97. package/runtime/numbers.md +79 -73
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +3 -9
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +13 -13
  102. package/runtime/unsafe/memory.gr +24 -20
  103. package/runtime/unsafe/memory.md +27 -7
  104. package/runtime/unsafe/offsets.gr +36 -0
  105. package/runtime/unsafe/offsets.md +88 -0
  106. package/runtime/unsafe/panic.gr +28 -0
  107. package/runtime/unsafe/panic.md +14 -0
  108. package/runtime/unsafe/tags.md +32 -32
  109. package/runtime/unsafe/wasmf32.md +28 -28
  110. package/runtime/unsafe/wasmf64.md +28 -28
  111. package/runtime/unsafe/wasmi32.md +47 -47
  112. package/runtime/unsafe/wasmi64.md +50 -50
  113. package/runtime/utf8.gr +189 -0
  114. package/runtime/utf8.md +117 -0
  115. package/runtime/wasi.gr +4 -2
  116. package/runtime/wasi.md +138 -138
  117. package/set.gr +18 -11
  118. package/set.md +42 -36
  119. package/stack.gr +171 -2
  120. package/stack.md +297 -15
  121. package/string.gr +352 -557
  122. package/string.md +77 -34
  123. package/uint16.md +22 -22
  124. package/uint32.gr +25 -4
  125. package/uint32.md +63 -28
  126. package/uint64.gr +25 -5
  127. package/uint64.md +63 -28
  128. package/uint8.md +22 -22
  129. package/uri.gr +57 -53
  130. package/uri.md +11 -12
  131. package/wasi/file.gr +67 -59
  132. package/wasi/file.md +39 -39
  133. package/wasi/process.md +5 -5
  134. package/wasi/random.md +3 -3
  135. package/wasi/time.md +4 -4
  136. package/runtime/utils/printing.gr +0 -60
  137. package/runtime/utils/printing.md +0 -26
package/wasi/file.md CHANGED
@@ -509,7 +509,7 @@ Functions and constants included in the File module.
509
509
  ### File.**stdin**
510
510
 
511
511
  ```grain
512
- stdin : FileDescriptor
512
+ stdin: FileDescriptor
513
513
  ```
514
514
 
515
515
  The `FileDescriptor` for `stdin`.
@@ -517,7 +517,7 @@ The `FileDescriptor` for `stdin`.
517
517
  ### File.**stdout**
518
518
 
519
519
  ```grain
520
- stdout : FileDescriptor
520
+ stdout: FileDescriptor
521
521
  ```
522
522
 
523
523
  The `FileDescriptor` for `stdout`.
@@ -525,7 +525,7 @@ The `FileDescriptor` for `stdout`.
525
525
  ### File.**stderr**
526
526
 
527
527
  ```grain
528
- stderr : FileDescriptor
528
+ stderr: FileDescriptor
529
529
  ```
530
530
 
531
531
  The `FileDescriptor` for `stderr`.
@@ -533,7 +533,7 @@ The `FileDescriptor` for `stderr`.
533
533
  ### File.**pathOpen**
534
534
 
535
535
  ```grain
536
- pathOpen :
536
+ pathOpen:
537
537
  (dirFd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
538
538
  openFlags: List<OpenFlag>, rights: List<Rights>,
539
539
  rightsInheriting: List<Rights>, flags: List<FdFlag>) =>
@@ -563,7 +563,7 @@ Returns:
563
563
  ### File.**fdRead**
564
564
 
565
565
  ```grain
566
- fdRead :
566
+ fdRead:
567
567
  (fd: FileDescriptor, size: Number) => Result<(Bytes, Number), Exception>
568
568
  ```
569
569
 
@@ -585,7 +585,7 @@ Returns:
585
585
  ### File.**fdPread**
586
586
 
587
587
  ```grain
588
- fdPread :
588
+ fdPread:
589
589
  (fd: FileDescriptor, offset: Int64, size: Number) =>
590
590
  Result<(Bytes, Number), Exception>
591
591
  ```
@@ -614,7 +614,7 @@ No other changes yet.
614
614
  </details>
615
615
 
616
616
  ```grain
617
- fdPrestatGet : (fd: FileDescriptor) => Result<Prestat, Exception>
617
+ fdPrestatGet: (fd: FileDescriptor) => Result<Prestat, Exception>
618
618
  ```
619
619
 
620
620
  Get information about a preopened directory.
@@ -634,7 +634,7 @@ Returns:
634
634
  ### File.**fdWrite**
635
635
 
636
636
  ```grain
637
- fdWrite : (fd: FileDescriptor, data: Bytes) => Result<Number, Exception>
637
+ fdWrite: (fd: FileDescriptor, data: Bytes) => Result<Number, Exception>
638
638
  ```
639
639
 
640
640
  Write to a file descriptor.
@@ -655,7 +655,7 @@ Returns:
655
655
  ### File.**fdPwrite**
656
656
 
657
657
  ```grain
658
- fdPwrite :
658
+ fdPwrite:
659
659
  (fd: FileDescriptor, data: Bytes, offset: Int64) =>
660
660
  Result<Number, Exception>
661
661
  ```
@@ -679,7 +679,7 @@ Returns:
679
679
  ### File.**fdAllocate**
680
680
 
681
681
  ```grain
682
- fdAllocate :
682
+ fdAllocate:
683
683
  (fd: FileDescriptor, offset: Int64, size: Int64) => Result<Void, Exception>
684
684
  ```
685
685
 
@@ -702,7 +702,7 @@ Returns:
702
702
  ### File.**fdClose**
703
703
 
704
704
  ```grain
705
- fdClose : (fd: FileDescriptor) => Result<Void, Exception>
705
+ fdClose: (fd: FileDescriptor) => Result<Void, Exception>
706
706
  ```
707
707
 
708
708
  Close a file descriptor.
@@ -722,7 +722,7 @@ Returns:
722
722
  ### File.**fdDatasync**
723
723
 
724
724
  ```grain
725
- fdDatasync : (fd: FileDescriptor) => Result<Void, Exception>
725
+ fdDatasync: (fd: FileDescriptor) => Result<Void, Exception>
726
726
  ```
727
727
 
728
728
  Synchronize the data of a file to disk.
@@ -742,7 +742,7 @@ Returns:
742
742
  ### File.**fdSync**
743
743
 
744
744
  ```grain
745
- fdSync : (fd: FileDescriptor) => Result<Void, Exception>
745
+ fdSync: (fd: FileDescriptor) => Result<Void, Exception>
746
746
  ```
747
747
 
748
748
  Synchronize the data and metadata of a file to disk.
@@ -762,7 +762,7 @@ Returns:
762
762
  ### File.**fdStats**
763
763
 
764
764
  ```grain
765
- fdStats : (fd: FileDescriptor) => Result<Stats, Exception>
765
+ fdStats: (fd: FileDescriptor) => Result<Stats, Exception>
766
766
  ```
767
767
 
768
768
  Retrieve information about a file descriptor.
@@ -782,7 +782,7 @@ Returns:
782
782
  ### File.**fdSetFlags**
783
783
 
784
784
  ```grain
785
- fdSetFlags :
785
+ fdSetFlags:
786
786
  (fd: FileDescriptor, flags: List<FdFlag>) => Result<Void, Exception>
787
787
  ```
788
788
 
@@ -804,7 +804,7 @@ Returns:
804
804
  ### File.**fdSetRights**
805
805
 
806
806
  ```grain
807
- fdSetRights :
807
+ fdSetRights:
808
808
  (fd: FileDescriptor, rights: List<Rights>, rightsInheriting: List<Rights>) =>
809
809
  Result<Void, Exception>
810
810
  ```
@@ -828,7 +828,7 @@ Returns:
828
828
  ### File.**fdFilestats**
829
829
 
830
830
  ```grain
831
- fdFilestats : (fd: FileDescriptor) => Result<Filestats, Exception>
831
+ fdFilestats: (fd: FileDescriptor) => Result<Filestats, Exception>
832
832
  ```
833
833
 
834
834
  Retrieve information about a file.
@@ -848,7 +848,7 @@ Returns:
848
848
  ### File.**fdSetSize**
849
849
 
850
850
  ```grain
851
- fdSetSize : (fd: FileDescriptor, size: Int64) => Result<Void, Exception>
851
+ fdSetSize: (fd: FileDescriptor, size: Int64) => Result<Void, Exception>
852
852
  ```
853
853
 
854
854
  Set (truncate) the size of a file.
@@ -869,7 +869,7 @@ Returns:
869
869
  ### File.**fdSetAccessTime**
870
870
 
871
871
  ```grain
872
- fdSetAccessTime :
872
+ fdSetAccessTime:
873
873
  (fd: FileDescriptor, timestamp: Int64) => Result<Void, Exception>
874
874
  ```
875
875
 
@@ -891,7 +891,7 @@ Returns:
891
891
  ### File.**fdSetAccessTimeNow**
892
892
 
893
893
  ```grain
894
- fdSetAccessTimeNow : (fd: FileDescriptor) => Result<Void, Exception>
894
+ fdSetAccessTimeNow: (fd: FileDescriptor) => Result<Void, Exception>
895
895
  ```
896
896
 
897
897
  Set the access (created) time of a file to the current time.
@@ -911,7 +911,7 @@ Returns:
911
911
  ### File.**fdSetModifiedTime**
912
912
 
913
913
  ```grain
914
- fdSetModifiedTime :
914
+ fdSetModifiedTime:
915
915
  (fd: FileDescriptor, timestamp: Int64) => Result<Void, Exception>
916
916
  ```
917
917
 
@@ -933,7 +933,7 @@ Returns:
933
933
  ### File.**fdSetModifiedTimeNow**
934
934
 
935
935
  ```grain
936
- fdSetModifiedTimeNow : (fd: FileDescriptor) => Result<Void, Exception>
936
+ fdSetModifiedTimeNow: (fd: FileDescriptor) => Result<Void, Exception>
937
937
  ```
938
938
 
939
939
  Set the modified time of a file to the current time.
@@ -953,7 +953,7 @@ Returns:
953
953
  ### File.**fdReaddir**
954
954
 
955
955
  ```grain
956
- fdReaddir : (fd: FileDescriptor) => Result<Array<DirectoryEntry>, Exception>
956
+ fdReaddir: (fd: FileDescriptor) => Result<Array<DirectoryEntry>, Exception>
957
957
  ```
958
958
 
959
959
  Read the entires of a directory.
@@ -973,7 +973,7 @@ Returns:
973
973
  ### File.**fdRenumber**
974
974
 
975
975
  ```grain
976
- fdRenumber :
976
+ fdRenumber:
977
977
  (fromFd: FileDescriptor, toFd: FileDescriptor) => Result<Void, Exception>
978
978
  ```
979
979
 
@@ -995,7 +995,7 @@ Returns:
995
995
  ### File.**fdSeek**
996
996
 
997
997
  ```grain
998
- fdSeek :
998
+ fdSeek:
999
999
  (fd: FileDescriptor, offset: Int64, whence: Whence) =>
1000
1000
  Result<Int64, Exception>
1001
1001
  ```
@@ -1019,7 +1019,7 @@ Returns:
1019
1019
  ### File.**fdTell**
1020
1020
 
1021
1021
  ```grain
1022
- fdTell : (fd: FileDescriptor) => Result<Int64, Exception>
1022
+ fdTell: (fd: FileDescriptor) => Result<Int64, Exception>
1023
1023
  ```
1024
1024
 
1025
1025
  Read a file descriptor's offset.
@@ -1039,7 +1039,7 @@ Returns:
1039
1039
  ### File.**pathCreateDirectory**
1040
1040
 
1041
1041
  ```grain
1042
- pathCreateDirectory :
1042
+ pathCreateDirectory:
1043
1043
  (fd: FileDescriptor, path: String) => Result<Void, Exception>
1044
1044
  ```
1045
1045
 
@@ -1061,7 +1061,7 @@ Returns:
1061
1061
  ### File.**pathFilestats**
1062
1062
 
1063
1063
  ```grain
1064
- pathFilestats :
1064
+ pathFilestats:
1065
1065
  (fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
1066
1066
  Result<Filestats, Exception>
1067
1067
  ```
@@ -1085,7 +1085,7 @@ Returns:
1085
1085
  ### File.**pathSetAccessTime**
1086
1086
 
1087
1087
  ```grain
1088
- pathSetAccessTime :
1088
+ pathSetAccessTime:
1089
1089
  (fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
1090
1090
  timestamp: Int64) => Result<Void, Exception>
1091
1091
  ```
@@ -1110,7 +1110,7 @@ Returns:
1110
1110
  ### File.**pathSetAccessTimeNow**
1111
1111
 
1112
1112
  ```grain
1113
- pathSetAccessTimeNow :
1113
+ pathSetAccessTimeNow:
1114
1114
  (fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
1115
1115
  Result<Void, Exception>
1116
1116
  ```
@@ -1134,7 +1134,7 @@ Returns:
1134
1134
  ### File.**pathSetModifiedTime**
1135
1135
 
1136
1136
  ```grain
1137
- pathSetModifiedTime :
1137
+ pathSetModifiedTime:
1138
1138
  (fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String,
1139
1139
  timestamp: Int64) => Result<Void, Exception>
1140
1140
  ```
@@ -1159,7 +1159,7 @@ Returns:
1159
1159
  ### File.**pathSetModifiedTimeNow**
1160
1160
 
1161
1161
  ```grain
1162
- pathSetModifiedTimeNow :
1162
+ pathSetModifiedTimeNow:
1163
1163
  (fd: FileDescriptor, dirFlags: List<LookupFlag>, path: String) =>
1164
1164
  Result<Void, Exception>
1165
1165
  ```
@@ -1183,7 +1183,7 @@ Returns:
1183
1183
  ### File.**pathLink**
1184
1184
 
1185
1185
  ```grain
1186
- pathLink :
1186
+ pathLink:
1187
1187
  (sourceFd: FileDescriptor, dirFlags: List<LookupFlag>, sourcePath:
1188
1188
  String, targetFd: FileDescriptor, targetPath: String) =>
1189
1189
  Result<Void, Exception>
@@ -1210,7 +1210,7 @@ Returns:
1210
1210
  ### File.**pathSymlink**
1211
1211
 
1212
1212
  ```grain
1213
- pathSymlink :
1213
+ pathSymlink:
1214
1214
  (fd: FileDescriptor, sourcePath: String, targetPath: String) =>
1215
1215
  Result<Void, Exception>
1216
1216
  ```
@@ -1234,7 +1234,7 @@ Returns:
1234
1234
  ### File.**pathUnlink**
1235
1235
 
1236
1236
  ```grain
1237
- pathUnlink : (fd: FileDescriptor, path: String) => Result<Void, Exception>
1237
+ pathUnlink: (fd: FileDescriptor, path: String) => Result<Void, Exception>
1238
1238
  ```
1239
1239
 
1240
1240
  Unlink a file.
@@ -1255,7 +1255,7 @@ Returns:
1255
1255
  ### File.**pathReadlink**
1256
1256
 
1257
1257
  ```grain
1258
- pathReadlink :
1258
+ pathReadlink:
1259
1259
  (fd: FileDescriptor, path: String, size: Number) =>
1260
1260
  Result<(String, Number), Exception>
1261
1261
  ```
@@ -1279,7 +1279,7 @@ Returns:
1279
1279
  ### File.**pathRemoveDirectory**
1280
1280
 
1281
1281
  ```grain
1282
- pathRemoveDirectory :
1282
+ pathRemoveDirectory:
1283
1283
  (fd: FileDescriptor, path: String) => Result<Void, Exception>
1284
1284
  ```
1285
1285
 
@@ -1301,7 +1301,7 @@ Returns:
1301
1301
  ### File.**pathRename**
1302
1302
 
1303
1303
  ```grain
1304
- pathRename :
1304
+ pathRename:
1305
1305
  (sourceFd: FileDescriptor, sourcePath: String, targetFd: FileDescriptor,
1306
1306
  targetPath: String) => Result<Void, Exception>
1307
1307
  ```
@@ -1331,7 +1331,7 @@ No other changes yet.
1331
1331
  </details>
1332
1332
 
1333
1333
  ```grain
1334
- open :
1334
+ open:
1335
1335
  (path: String, openFlags: List<OpenFlag>, rights: List<Rights>,
1336
1336
  rightsInheriting: List<Rights>, flags: List<FdFlag>) =>
1337
1337
  Result<FileDescriptor, Exception>
package/wasi/process.md CHANGED
@@ -218,7 +218,7 @@ Functions and constants included in the Process module.
218
218
  ### Process.**argv**
219
219
 
220
220
  ```grain
221
- argv : () => Result<Array<String>, Exception>
221
+ argv: () => Result<Array<String>, Exception>
222
222
  ```
223
223
 
224
224
  Access command line arguments.
@@ -232,7 +232,7 @@ Returns:
232
232
  ### Process.**env**
233
233
 
234
234
  ```grain
235
- env : () => Result<Array<String>, Exception>
235
+ env: () => Result<Array<String>, Exception>
236
236
  ```
237
237
 
238
238
  Access environment variables.
@@ -246,7 +246,7 @@ Returns:
246
246
  ### Process.**exit**
247
247
 
248
248
  ```grain
249
- exit : (code: Number) => Result<Void, Exception>
249
+ exit: (code: Number) => Result<Void, Exception>
250
250
  ```
251
251
 
252
252
  Terminate the process normally.
@@ -266,7 +266,7 @@ Returns:
266
266
  ### Process.**sigRaise**
267
267
 
268
268
  ```grain
269
- sigRaise : (signal: Signal) => Result<Void, Exception>
269
+ sigRaise: (signal: Signal) => Result<Void, Exception>
270
270
  ```
271
271
 
272
272
  Send a signal to the process of the calling thread.
@@ -286,7 +286,7 @@ Returns:
286
286
  ### Process.**schedYield**
287
287
 
288
288
  ```grain
289
- schedYield : () => Result<Void, Exception>
289
+ schedYield: () => Result<Void, Exception>
290
290
  ```
291
291
 
292
292
  Yield execution to the calling thread.
package/wasi/random.md CHANGED
@@ -27,7 +27,7 @@ Functions and constants included in the Random module.
27
27
  </details>
28
28
 
29
29
  ```grain
30
- randomUint32 : () => Result<Uint32, Exception>
30
+ randomUint32: () => Result<Uint32, Exception>
31
31
  ```
32
32
 
33
33
  Produce a random 32-bit integer. This function can be slow, so it's best to seed a generator if lots of random data is needed.
@@ -53,7 +53,7 @@ Returns:
53
53
  </details>
54
54
 
55
55
  ```grain
56
- randomUint64 : () => Result<Uint64, Exception>
56
+ randomUint64: () => Result<Uint64, Exception>
57
57
  ```
58
58
 
59
59
  Produce a random 64-bit integer. This function can be slow, so it's best to seed a generator if lots of random data is needed.
@@ -67,7 +67,7 @@ Returns:
67
67
  ### Random.**random**
68
68
 
69
69
  ```grain
70
- random : () => Result<Number, Exception>
70
+ random: () => Result<Number, Exception>
71
71
  ```
72
72
 
73
73
  Produce a random number. This function can be slow, so it's best to seed a generator if lots of random data is needed.
package/wasi/time.md CHANGED
@@ -15,7 +15,7 @@ Functions and constants included in the Time module.
15
15
  ### Time.**realTime**
16
16
 
17
17
  ```grain
18
- realTime : () => Result<Int64, Exception>
18
+ realTime: () => Result<Int64, Exception>
19
19
  ```
20
20
 
21
21
  Get the current time, in nanoseconds.
@@ -30,7 +30,7 @@ Returns:
30
30
  ### Time.**monotonicTime**
31
31
 
32
32
  ```grain
33
- monotonicTime : () => Result<Int64, Exception>
33
+ monotonicTime: () => Result<Int64, Exception>
34
34
  ```
35
35
 
36
36
  Get the time of the system's high-resolution clock, in nanoseconds.
@@ -47,7 +47,7 @@ Returns:
47
47
  ### Time.**processCpuTime**
48
48
 
49
49
  ```grain
50
- processCpuTime : () => Result<Int64, Exception>
50
+ processCpuTime: () => Result<Int64, Exception>
51
51
  ```
52
52
 
53
53
  Get the number of nanoseconds elapsed since the process began.
@@ -61,7 +61,7 @@ Returns:
61
61
  ### Time.**threadCpuTime**
62
62
 
63
63
  ```grain
64
- threadCpuTime : () => Result<Int64, Exception>
64
+ threadCpuTime: () => Result<Int64, Exception>
65
65
  ```
66
66
 
67
67
  Get the number of nanoseconds elapsed since the thread began.
@@ -1,60 +0,0 @@
1
- @noPervasives
2
- module Printing
3
-
4
- // Printing utilities for runtime code (primarily for debugging)
5
- from "runtime/unsafe/wasmi32" include WasmI32
6
- from "runtime/unsafe/memory" include Memory
7
- from "runtime/numberUtils" include NumberUtils
8
-
9
- foreign wasm fd_write:
10
- (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "wasi_snapshot_preview1"
11
-
12
- @unsafe
13
- provide let numberToString = (n: WasmI64) => {
14
- NumberUtils.itoa64(n, 10n)
15
- }
16
-
17
- @unsafe
18
- provide let printNumber = (n: WasmI64) => {
19
- // like print(), but `s` should be a Grain string
20
- use WasmI32.{ (+) }
21
- let s = numberToString(n)
22
- let ptr = WasmI32.fromGrain(s)
23
- // iov: [<ptr to string> <nbytes of string> <ptr to newline> <nbytes of newline>] (32 bytes)
24
- // buf: <iov> <written> <newline char>
25
- // fd_write(STDOUT (1), iov, len(iov), written)
26
- let buf = Memory.malloc(37n)
27
- let iov = buf
28
- let written = buf + 32n
29
- let lf = buf + 36n
30
- WasmI32.store(iov, ptr + 8n, 0n)
31
- WasmI32.store(iov, WasmI32.load(ptr, 4n), 4n)
32
- WasmI32.store8(lf, 10n, 0n)
33
- WasmI32.store(iov, lf, 8n)
34
- WasmI32.store(iov, 1n, 12n)
35
- fd_write(1n, iov, 2n, written)
36
- Memory.free(buf)
37
- void
38
- }
39
-
40
- @unsafe
41
- provide let printString = (s: String) => {
42
- // like print(), but `s` should be a Grain string
43
- use WasmI32.{ (+) }
44
- let ptr = WasmI32.fromGrain(s)
45
- // iov: [<ptr to string> <nbytes of string> <ptr to newline> <nbytes of newline>] (32 bytes)
46
- // buf: <iov> <written> <newline char>
47
- // fd_write(STDOUT (1), iov, len(iov), written)
48
- let buf = Memory.malloc(37n)
49
- let iov = buf
50
- let written = buf + 32n
51
- let lf = buf + 36n
52
- WasmI32.store(iov, ptr + 8n, 0n)
53
- WasmI32.store(iov, WasmI32.load(ptr, 4n), 4n)
54
- WasmI32.store8(lf, 10n, 0n)
55
- WasmI32.store(iov, lf, 8n)
56
- WasmI32.store(iov, 1n, 12n)
57
- fd_write(1n, iov, 2n, written)
58
- Memory.free(buf)
59
- void
60
- }
@@ -1,26 +0,0 @@
1
- ---
2
- title: Printing
3
- ---
4
-
5
- ## Values
6
-
7
- Functions and constants included in the Printing module.
8
-
9
- ### Printing.**numberToString**
10
-
11
- ```grain
12
- numberToString : (n: WasmI64) => String
13
- ```
14
-
15
- ### Printing.**printNumber**
16
-
17
- ```grain
18
- printNumber : (n: WasmI64) => Void
19
- ```
20
-
21
- ### Printing.**printString**
22
-
23
- ```grain
24
- printString : (s: String) => Void
25
- ```
26
-