@grain/stdlib 0.5.13 → 0.6.1

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 (155) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/LICENSE +1 -1
  3. package/README.md +25 -2
  4. package/array.gr +1512 -199
  5. package/array.md +2032 -94
  6. package/bigint.gr +239 -140
  7. package/bigint.md +450 -106
  8. package/buffer.gr +595 -102
  9. package/buffer.md +903 -145
  10. package/bytes.gr +401 -110
  11. package/bytes.md +551 -63
  12. package/char.gr +228 -49
  13. package/char.md +373 -7
  14. package/exception.gr +26 -12
  15. package/exception.md +29 -5
  16. package/float32.gr +130 -109
  17. package/float32.md +185 -57
  18. package/float64.gr +112 -99
  19. package/float64.md +185 -57
  20. package/hash.gr +62 -40
  21. package/hash.md +27 -3
  22. package/int16.gr +430 -0
  23. package/int16.md +618 -0
  24. package/int32.gr +200 -269
  25. package/int32.md +254 -289
  26. package/int64.gr +142 -225
  27. package/int64.md +254 -289
  28. package/int8.gr +511 -0
  29. package/int8.md +786 -0
  30. package/json.gr +2071 -0
  31. package/json.md +646 -0
  32. package/list.gr +120 -68
  33. package/list.md +125 -80
  34. package/map.gr +560 -57
  35. package/map.md +672 -56
  36. package/marshal.gr +239 -227
  37. package/marshal.md +36 -4
  38. package/number.gr +626 -676
  39. package/number.md +738 -153
  40. package/option.gr +33 -35
  41. package/option.md +58 -42
  42. package/package.json +2 -2
  43. package/path.gr +148 -187
  44. package/path.md +47 -96
  45. package/pervasives.gr +75 -416
  46. package/pervasives.md +85 -180
  47. package/priorityqueue.gr +433 -74
  48. package/priorityqueue.md +422 -54
  49. package/queue.gr +362 -80
  50. package/queue.md +433 -38
  51. package/random.gr +67 -75
  52. package/random.md +68 -40
  53. package/range.gr +135 -63
  54. package/range.md +198 -43
  55. package/rational.gr +284 -0
  56. package/rational.md +545 -0
  57. package/regex.gr +933 -1066
  58. package/regex.md +59 -60
  59. package/result.gr +23 -25
  60. package/result.md +54 -39
  61. package/runtime/atof/common.gr +78 -82
  62. package/runtime/atof/common.md +22 -10
  63. package/runtime/atof/decimal.gr +102 -127
  64. package/runtime/atof/decimal.md +28 -7
  65. package/runtime/atof/lemire.gr +56 -71
  66. package/runtime/atof/lemire.md +9 -1
  67. package/runtime/atof/parse.gr +83 -110
  68. package/runtime/atof/parse.md +12 -2
  69. package/runtime/atof/slow.gr +28 -35
  70. package/runtime/atof/slow.md +9 -1
  71. package/runtime/atof/table.gr +19 -18
  72. package/runtime/atof/table.md +10 -2
  73. package/runtime/atoi/parse.gr +153 -136
  74. package/runtime/atoi/parse.md +50 -1
  75. package/runtime/bigint.gr +410 -517
  76. package/runtime/bigint.md +71 -57
  77. package/runtime/compare.gr +176 -85
  78. package/runtime/compare.md +31 -1
  79. package/runtime/dataStructures.gr +144 -32
  80. package/runtime/dataStructures.md +267 -31
  81. package/runtime/debugPrint.gr +34 -15
  82. package/runtime/debugPrint.md +37 -5
  83. package/runtime/equal.gr +53 -52
  84. package/runtime/equal.md +30 -1
  85. package/runtime/exception.gr +38 -47
  86. package/runtime/exception.md +10 -8
  87. package/runtime/gc.gr +23 -152
  88. package/runtime/gc.md +13 -17
  89. package/runtime/malloc.gr +31 -31
  90. package/runtime/malloc.md +11 -3
  91. package/runtime/numberUtils.gr +193 -174
  92. package/runtime/numberUtils.md +29 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +543 -245
  96. package/runtime/string.md +76 -6
  97. package/runtime/unsafe/constants.gr +30 -13
  98. package/runtime/unsafe/constants.md +80 -0
  99. package/runtime/unsafe/conv.gr +55 -28
  100. package/runtime/unsafe/conv.md +41 -9
  101. package/runtime/unsafe/memory.gr +10 -30
  102. package/runtime/unsafe/memory.md +15 -19
  103. package/runtime/unsafe/tags.gr +37 -21
  104. package/runtime/unsafe/tags.md +88 -8
  105. package/runtime/unsafe/wasmf32.gr +30 -36
  106. package/runtime/unsafe/wasmf32.md +64 -56
  107. package/runtime/unsafe/wasmf64.gr +30 -36
  108. package/runtime/unsafe/wasmf64.md +64 -56
  109. package/runtime/unsafe/wasmi32.gr +49 -66
  110. package/runtime/unsafe/wasmi32.md +102 -94
  111. package/runtime/unsafe/wasmi64.gr +52 -79
  112. package/runtime/unsafe/wasmi64.md +108 -100
  113. package/runtime/utils/printing.gr +13 -15
  114. package/runtime/utils/printing.md +11 -3
  115. package/runtime/wasi.gr +294 -295
  116. package/runtime/wasi.md +62 -42
  117. package/set.gr +574 -64
  118. package/set.md +634 -54
  119. package/stack.gr +181 -64
  120. package/stack.md +271 -42
  121. package/string.gr +453 -533
  122. package/string.md +241 -151
  123. package/uint16.gr +369 -0
  124. package/uint16.md +585 -0
  125. package/uint32.gr +470 -0
  126. package/uint32.md +737 -0
  127. package/uint64.gr +471 -0
  128. package/uint64.md +737 -0
  129. package/uint8.gr +369 -0
  130. package/uint8.md +585 -0
  131. package/uri.gr +1093 -0
  132. package/uri.md +477 -0
  133. package/{sys → wasi}/file.gr +914 -500
  134. package/{sys → wasi}/file.md +454 -50
  135. package/wasi/process.gr +292 -0
  136. package/{sys → wasi}/process.md +164 -6
  137. package/wasi/random.gr +77 -0
  138. package/wasi/random.md +80 -0
  139. package/{sys → wasi}/time.gr +15 -22
  140. package/{sys → wasi}/time.md +5 -5
  141. package/immutablearray.gr +0 -929
  142. package/immutablearray.md +0 -1038
  143. package/immutablemap.gr +0 -493
  144. package/immutablemap.md +0 -479
  145. package/immutablepriorityqueue.gr +0 -360
  146. package/immutablepriorityqueue.md +0 -291
  147. package/immutableset.gr +0 -498
  148. package/immutableset.md +0 -449
  149. package/runtime/debug.gr +0 -2
  150. package/runtime/debug.md +0 -6
  151. package/runtime/unsafe/errors.gr +0 -36
  152. package/runtime/unsafe/errors.md +0 -204
  153. package/sys/process.gr +0 -254
  154. package/sys/random.gr +0 -79
  155. package/sys/random.md +0 -66
@@ -1,7 +1,15 @@
1
+ ---
2
+ title: DataStructures
3
+ ---
4
+
5
+ ## Values
6
+
7
+ Functions and constants included in the DataStructures module.
8
+
1
9
  ### DataStructures.**allocateArray**
2
10
 
3
11
  ```grain
4
- allocateArray : WasmI32 -> WasmI32
12
+ allocateArray : (size: WasmI32) => WasmI32
5
13
  ```
6
14
 
7
15
  Allocates a new Grain array.
@@ -10,7 +18,7 @@ Parameters:
10
18
 
11
19
  |param|type|description|
12
20
  |-----|----|-----------|
13
- |`numElts`|`WasmI32`|The number of elements to be contained in this array|
21
+ |`size`|`WasmI32`|The number of elements to be contained in this array|
14
22
 
15
23
  Returns:
16
24
 
@@ -21,7 +29,7 @@ Returns:
21
29
  ### DataStructures.**allocateTuple**
22
30
 
23
31
  ```grain
24
- allocateTuple : WasmI32 -> WasmI32
32
+ allocateTuple : (size: WasmI32) => WasmI32
25
33
  ```
26
34
 
27
35
  Allocates a new Grain tuple.
@@ -30,7 +38,7 @@ Parameters:
30
38
 
31
39
  |param|type|description|
32
40
  |-----|----|-----------|
33
- |`numElts`|`WasmI32`|The number of elements to be contained in this tuple|
41
+ |`size`|`WasmI32`|The number of elements to be contained in this tuple|
34
42
 
35
43
  Returns:
36
44
 
@@ -41,7 +49,7 @@ Returns:
41
49
  ### DataStructures.**allocateBytes**
42
50
 
43
51
  ```grain
44
- allocateBytes : WasmI32 -> WasmI32
52
+ allocateBytes : (size: WasmI32) => WasmI32
45
53
  ```
46
54
 
47
55
  Allocates a new Grain bytes.
@@ -61,7 +69,7 @@ Returns:
61
69
  ### DataStructures.**allocateString**
62
70
 
63
71
  ```grain
64
- allocateString : WasmI32 -> WasmI32
72
+ allocateString : (size: WasmI32) => WasmI32
65
73
  ```
66
74
 
67
75
  Allocates a new Grain string.
@@ -81,7 +89,7 @@ Returns:
81
89
  ### DataStructures.**allocateInt32**
82
90
 
83
91
  ```grain
84
- allocateInt32 : () -> WasmI32
92
+ allocateInt32 : () => WasmI32
85
93
  ```
86
94
 
87
95
  Allocates a new Int32.
@@ -95,7 +103,7 @@ Returns:
95
103
  ### DataStructures.**newInt32**
96
104
 
97
105
  ```grain
98
- newInt32 : WasmI32 -> WasmI32
106
+ newInt32 : (int: WasmI32) => WasmI32
99
107
  ```
100
108
 
101
109
  Allocates a new Int32 with a prepopulated value
@@ -104,7 +112,7 @@ Parameters:
104
112
 
105
113
  |param|type|description|
106
114
  |-----|----|-----------|
107
- |`value`|`WasmI32`|The value to store|
115
+ |`int`|`WasmI32`|The value to store|
108
116
 
109
117
  Returns:
110
118
 
@@ -112,10 +120,44 @@ Returns:
112
120
  |----|-----------|
113
121
  |`WasmI32`|The pointer to the Int32|
114
122
 
123
+ ### DataStructures.**allocateUint32**
124
+
125
+ ```grain
126
+ allocateUint32 : () => WasmI32
127
+ ```
128
+
129
+ Allocates a new Uint32.
130
+
131
+ Returns:
132
+
133
+ |type|description|
134
+ |----|-----------|
135
+ |`WasmI32`|The pointer to the empty Uint32|
136
+
137
+ ### DataStructures.**newUint32**
138
+
139
+ ```grain
140
+ newUint32 : (int: WasmI32) => WasmI32
141
+ ```
142
+
143
+ Allocates a new Uint32 with a prepopulated value
144
+
145
+ Parameters:
146
+
147
+ |param|type|description|
148
+ |-----|----|-----------|
149
+ |`int`|`WasmI32`|The value to store|
150
+
151
+ Returns:
152
+
153
+ |type|description|
154
+ |----|-----------|
155
+ |`WasmI32`|The pointer to the Uint32|
156
+
115
157
  ### DataStructures.**allocateInt64**
116
158
 
117
159
  ```grain
118
- allocateInt64 : () -> WasmI32
160
+ allocateInt64 : () => WasmI32
119
161
  ```
120
162
 
121
163
  Allocates a new Int64.
@@ -129,7 +171,7 @@ Returns:
129
171
  ### DataStructures.**newInt64**
130
172
 
131
173
  ```grain
132
- newInt64 : WasmI64 -> WasmI32
174
+ newInt64 : (int: WasmI64) => WasmI32
133
175
  ```
134
176
 
135
177
  Allocates a new Int64 with a prepopulated value
@@ -138,7 +180,7 @@ Parameters:
138
180
 
139
181
  |param|type|description|
140
182
  |-----|----|-----------|
141
- |`value`|`WasmI64`|The value to store|
183
+ |`int`|`WasmI64`|The value to store|
142
184
 
143
185
  Returns:
144
186
 
@@ -146,10 +188,44 @@ Returns:
146
188
  |----|-----------|
147
189
  |`WasmI32`|The pointer to the Int64|
148
190
 
191
+ ### DataStructures.**allocateUint64**
192
+
193
+ ```grain
194
+ allocateUint64 : () => WasmI32
195
+ ```
196
+
197
+ Allocates a new Uint64.
198
+
199
+ Returns:
200
+
201
+ |type|description|
202
+ |----|-----------|
203
+ |`WasmI32`|The pointer to the empty Uint64|
204
+
205
+ ### DataStructures.**newUint64**
206
+
207
+ ```grain
208
+ newUint64 : (int: WasmI64) => WasmI32
209
+ ```
210
+
211
+ Allocates a new Uint64 with a prepopulated value
212
+
213
+ Parameters:
214
+
215
+ |param|type|description|
216
+ |-----|----|-----------|
217
+ |`int`|`WasmI64`|The value to store|
218
+
219
+ Returns:
220
+
221
+ |type|description|
222
+ |----|-----------|
223
+ |`WasmI32`|The pointer to the Uint64|
224
+
149
225
  ### DataStructures.**allocateFloat32**
150
226
 
151
227
  ```grain
152
- allocateFloat32 : () -> WasmI32
228
+ allocateFloat32 : () => WasmI32
153
229
  ```
154
230
 
155
231
  Allocates a new Float32.
@@ -163,7 +239,7 @@ Returns:
163
239
  ### DataStructures.**newFloat32**
164
240
 
165
241
  ```grain
166
- newFloat32 : WasmF32 -> WasmI32
242
+ newFloat32 : (float: WasmF32) => WasmI32
167
243
  ```
168
244
 
169
245
  Allocates a new Float32 with a prepopulated value
@@ -172,7 +248,7 @@ Parameters:
172
248
 
173
249
  |param|type|description|
174
250
  |-----|----|-----------|
175
- |`value`|`WasmF32`|The value to store|
251
+ |`float`|`WasmF32`|The value to store|
176
252
 
177
253
  Returns:
178
254
 
@@ -183,7 +259,7 @@ Returns:
183
259
  ### DataStructures.**allocateFloat64**
184
260
 
185
261
  ```grain
186
- allocateFloat64 : () -> WasmI32
262
+ allocateFloat64 : () => WasmI32
187
263
  ```
188
264
 
189
265
  Allocates a new Float64.
@@ -197,7 +273,7 @@ Returns:
197
273
  ### DataStructures.**newFloat64**
198
274
 
199
275
  ```grain
200
- newFloat64 : WasmF64 -> WasmI32
276
+ newFloat64 : (float: WasmF64) => WasmI32
201
277
  ```
202
278
 
203
279
  Allocates a new Float64 with a prepopulated value
@@ -206,7 +282,7 @@ Parameters:
206
282
 
207
283
  |param|type|description|
208
284
  |-----|----|-----------|
209
- |`value`|`WasmF64`|The value to store|
285
+ |`float`|`WasmF64`|The value to store|
210
286
 
211
287
  Returns:
212
288
 
@@ -217,7 +293,7 @@ Returns:
217
293
  ### DataStructures.**allocateRational**
218
294
 
219
295
  ```grain
220
- allocateRational : () -> WasmI32
296
+ allocateRational : () => WasmI32
221
297
  ```
222
298
 
223
299
  Allocates a new Rational.
@@ -231,7 +307,7 @@ Returns:
231
307
  ### DataStructures.**newRational**
232
308
 
233
309
  ```grain
234
- newRational : (WasmI32, WasmI32) -> WasmI32
310
+ newRational : (numerator: WasmI32, denominator: WasmI32) => WasmI32
235
311
  ```
236
312
 
237
313
  Allocates a new Rational with a prepopulated value
@@ -240,8 +316,8 @@ Parameters:
240
316
 
241
317
  |param|type|description|
242
318
  |-----|----|-----------|
243
- |`value`|`WasmI32`|The numerator value to store|
244
- |`value`|`WasmI32`|The denominator value to store|
319
+ |`numerator`|`WasmI32`|The numerator value to store|
320
+ |`denominator`|`WasmI32`|The denominator value to store|
245
321
 
246
322
  Returns:
247
323
 
@@ -252,7 +328,7 @@ Returns:
252
328
  ### DataStructures.**loadAdtVariant**
253
329
 
254
330
  ```grain
255
- loadAdtVariant : WasmI32 -> WasmI32
331
+ loadAdtVariant : (ptr: WasmI32) => WasmI32
256
332
  ```
257
333
 
258
334
  Load the (tagged) variant of an ADT.
@@ -272,7 +348,7 @@ Returns:
272
348
  ### DataStructures.**stringSize**
273
349
 
274
350
  ```grain
275
- stringSize : WasmI32 -> WasmI32
351
+ stringSize : (ptr: WasmI32) => WasmI32
276
352
  ```
277
353
 
278
354
  Load an untagged string's size.
@@ -292,7 +368,7 @@ Returns:
292
368
  ### DataStructures.**bytesSize**
293
369
 
294
370
  ```grain
295
- bytesSize : WasmI32 -> WasmI32
371
+ bytesSize : (ptr: WasmI32) => WasmI32
296
372
  ```
297
373
 
298
374
  Load an untagged Bytes' size.
@@ -312,7 +388,7 @@ Returns:
312
388
  ### DataStructures.**tagSimpleNumber**
313
389
 
314
390
  ```grain
315
- tagSimpleNumber : WasmI32 -> Number
391
+ tagSimpleNumber : (num: WasmI32) => Number
316
392
  ```
317
393
 
318
394
  Tag a simple number.
@@ -332,7 +408,7 @@ Returns:
332
408
  ### DataStructures.**untagSimpleNumber**
333
409
 
334
410
  ```grain
335
- untagSimpleNumber : Number -> WasmI32
411
+ untagSimpleNumber : (num: Number) => WasmI32
336
412
  ```
337
413
 
338
414
  Untag a simple number.
@@ -352,7 +428,7 @@ Returns:
352
428
  ### DataStructures.**tagChar**
353
429
 
354
430
  ```grain
355
- tagChar : WasmI32 -> Char
431
+ tagChar : (char: WasmI32) => Char
356
432
  ```
357
433
 
358
434
  Tag a char.
@@ -361,7 +437,7 @@ Parameters:
361
437
 
362
438
  |param|type|description|
363
439
  |-----|----|-----------|
364
- |`num`|`WasmI32`|The usv to tag|
440
+ |`char`|`WasmI32`|The usv to tag|
365
441
 
366
442
  Returns:
367
443
 
@@ -372,7 +448,7 @@ Returns:
372
448
  ### DataStructures.**untagChar**
373
449
 
374
450
  ```grain
375
- untagChar : Char -> WasmI32
451
+ untagChar : (char: Char) => WasmI32
376
452
  ```
377
453
 
378
454
  Untag a char.
@@ -381,7 +457,7 @@ Parameters:
381
457
 
382
458
  |param|type|description|
383
459
  |-----|----|-----------|
384
- |`num`|`Char`|The char to untag|
460
+ |`char`|`Char`|The char to untag|
385
461
 
386
462
  Returns:
387
463
 
@@ -389,3 +465,163 @@ Returns:
389
465
  |----|-----------|
390
466
  |`WasmI32`|The untagged usv|
391
467
 
468
+ ### DataStructures.**tagInt8**
469
+
470
+ ```grain
471
+ tagInt8 : (int: WasmI32) => Int8
472
+ ```
473
+
474
+ Tag an int8.
475
+
476
+ Parameters:
477
+
478
+ |param|type|description|
479
+ |-----|----|-----------|
480
+ |`int`|`WasmI32`|The int8 to tag|
481
+
482
+ Returns:
483
+
484
+ |type|description|
485
+ |----|-----------|
486
+ |`Int8`|The tagged int8|
487
+
488
+ ### DataStructures.**untagInt8**
489
+
490
+ ```grain
491
+ untagInt8 : (int: Int8) => WasmI32
492
+ ```
493
+
494
+ Untag an int8.
495
+
496
+ Parameters:
497
+
498
+ |param|type|description|
499
+ |-----|----|-----------|
500
+ |`int`|`Int8`|The int8 to untag|
501
+
502
+ Returns:
503
+
504
+ |type|description|
505
+ |----|-----------|
506
+ |`WasmI32`|The untagged int8|
507
+
508
+ ### DataStructures.**tagInt16**
509
+
510
+ ```grain
511
+ tagInt16 : (int: WasmI32) => Int16
512
+ ```
513
+
514
+ Tag an int16.
515
+
516
+ Parameters:
517
+
518
+ |param|type|description|
519
+ |-----|----|-----------|
520
+ |`int`|`WasmI32`|The int16 to tag|
521
+
522
+ Returns:
523
+
524
+ |type|description|
525
+ |----|-----------|
526
+ |`Int16`|The tagged int16|
527
+
528
+ ### DataStructures.**untagInt16**
529
+
530
+ ```grain
531
+ untagInt16 : (int: Int16) => WasmI32
532
+ ```
533
+
534
+ Untag an int16.
535
+
536
+ Parameters:
537
+
538
+ |param|type|description|
539
+ |-----|----|-----------|
540
+ |`int`|`Int16`|The int16 to untag|
541
+
542
+ Returns:
543
+
544
+ |type|description|
545
+ |----|-----------|
546
+ |`WasmI32`|The untagged int16|
547
+
548
+ ### DataStructures.**tagUint8**
549
+
550
+ ```grain
551
+ tagUint8 : (int: WasmI32) => Uint8
552
+ ```
553
+
554
+ Tag a uint8.
555
+
556
+ Parameters:
557
+
558
+ |param|type|description|
559
+ |-----|----|-----------|
560
+ |`int`|`WasmI32`|The uint8 to tag|
561
+
562
+ Returns:
563
+
564
+ |type|description|
565
+ |----|-----------|
566
+ |`Uint8`|The tagged uint8|
567
+
568
+ ### DataStructures.**untagUint8**
569
+
570
+ ```grain
571
+ untagUint8 : (int: Uint8) => WasmI32
572
+ ```
573
+
574
+ Untag a uint8.
575
+
576
+ Parameters:
577
+
578
+ |param|type|description|
579
+ |-----|----|-----------|
580
+ |`int`|`Uint8`|The uint8 to untag|
581
+
582
+ Returns:
583
+
584
+ |type|description|
585
+ |----|-----------|
586
+ |`WasmI32`|The untagged uint8|
587
+
588
+ ### DataStructures.**tagUint16**
589
+
590
+ ```grain
591
+ tagUint16 : (int: WasmI32) => Uint16
592
+ ```
593
+
594
+ Tag a uint16.
595
+
596
+ Parameters:
597
+
598
+ |param|type|description|
599
+ |-----|----|-----------|
600
+ |`int`|`WasmI32`|The uint16 to tag|
601
+
602
+ Returns:
603
+
604
+ |type|description|
605
+ |----|-----------|
606
+ |`Uint16`|The tagged uint16|
607
+
608
+ ### DataStructures.**untagUint16**
609
+
610
+ ```grain
611
+ untagUint16 : (int: Uint16) => WasmI32
612
+ ```
613
+
614
+ Untag a uint16.
615
+
616
+ Parameters:
617
+
618
+ |param|type|description|
619
+ |-----|----|-----------|
620
+ |`int`|`Uint16`|The uint16 to untag|
621
+
622
+ Returns:
623
+
624
+ |type|description|
625
+ |----|-----------|
626
+ |`WasmI32`|The untagged uint16|
627
+
@@ -1,17 +1,16 @@
1
- import Utils from "runtime/numberUtils"
2
- import WasmI32, { add as (+) } from "runtime/unsafe/wasmi32"
3
- import WasmF64 from "runtime/unsafe/wasmf64"
4
- import Memory from "runtime/unsafe/memory"
1
+ module DebugPrint
5
2
 
6
- import foreign wasm fd_write: (
7
- WasmI32,
8
- WasmI32,
9
- WasmI32,
10
- WasmI32,
11
- ) -> WasmI32 from "wasi_snapshot_preview1"
3
+ from "runtime/numberUtils" include NumberUtils as Utils
4
+ from "runtime/unsafe/wasmi32" include WasmI32
5
+ use WasmI32.{ (+) }
6
+ from "runtime/unsafe/wasmf64" include WasmF64
7
+ from "runtime/unsafe/memory" include Memory
8
+
9
+ foreign wasm fd_write:
10
+ (WasmI32, WasmI32, WasmI32, WasmI32) => WasmI32 from "wasi_snapshot_preview1"
12
11
 
13
12
  @unsafe
14
- export let print = (s: String) => {
13
+ provide let print = (s: String) => {
15
14
  let ptr = WasmI32.fromGrain(s)
16
15
  // iov: [<ptr to string> <nbytes of string> <ptr to newline> <nbytes of newline>] (32 bytes)
17
16
  // buf: <iov> <written> <newline char>
@@ -31,21 +30,41 @@ export let print = (s: String) => {
31
30
  }
32
31
 
33
32
  @unsafe
34
- export let printI32 = val => {
33
+ provide let printI32 = val => {
35
34
  print(Utils.itoa32(val, 10n))
36
35
  }
37
36
 
38
37
  @unsafe
39
- export let printI64 = val => {
38
+ provide let printI64 = val => {
40
39
  print(Utils.itoa64(val, 10n))
41
40
  }
42
41
 
43
42
  @unsafe
44
- export let printF32 = val => {
43
+ provide let printF32 = val => {
45
44
  print(Utils.dtoa(WasmF64.promoteF32(val)))
46
45
  }
47
46
 
48
47
  @unsafe
49
- export let printF64 = val => {
48
+ provide let printF64 = val => {
50
49
  print(Utils.dtoa(val))
51
50
  }
51
+
52
+ @unsafe
53
+ provide let toStringI32 = val => {
54
+ Utils.itoa32(val, 10n)
55
+ }
56
+
57
+ @unsafe
58
+ provide let toStringI64 = val => {
59
+ Utils.itoa64(val, 10n)
60
+ }
61
+
62
+ @unsafe
63
+ provide let toStringF32 = val => {
64
+ Utils.dtoa(WasmF64.promoteF32(val))
65
+ }
66
+
67
+ @unsafe
68
+ provide let toStringF64 = val => {
69
+ Utils.dtoa(val)
70
+ }
@@ -1,30 +1,62 @@
1
+ ---
2
+ title: DebugPrint
3
+ ---
4
+
5
+ ## Values
6
+
7
+ Functions and constants included in the DebugPrint module.
8
+
1
9
  ### DebugPrint.**print**
2
10
 
3
11
  ```grain
4
- print : String -> Void
12
+ print : (s: String) => Void
5
13
  ```
6
14
 
7
15
  ### DebugPrint.**printI32**
8
16
 
9
17
  ```grain
10
- printI32 : WasmI32 -> Void
18
+ printI32 : (val: WasmI32) => Void
11
19
  ```
12
20
 
13
21
  ### DebugPrint.**printI64**
14
22
 
15
23
  ```grain
16
- printI64 : WasmI64 -> Void
24
+ printI64 : (val: WasmI64) => Void
17
25
  ```
18
26
 
19
27
  ### DebugPrint.**printF32**
20
28
 
21
29
  ```grain
22
- printF32 : WasmF32 -> Void
30
+ printF32 : (val: WasmF32) => Void
23
31
  ```
24
32
 
25
33
  ### DebugPrint.**printF64**
26
34
 
27
35
  ```grain
28
- printF64 : WasmF64 -> Void
36
+ printF64 : (val: WasmF64) => Void
37
+ ```
38
+
39
+ ### DebugPrint.**toStringI32**
40
+
41
+ ```grain
42
+ toStringI32 : (val: WasmI32) => String
43
+ ```
44
+
45
+ ### DebugPrint.**toStringI64**
46
+
47
+ ```grain
48
+ toStringI64 : (val: WasmI64) => String
49
+ ```
50
+
51
+ ### DebugPrint.**toStringF32**
52
+
53
+ ```grain
54
+ toStringF32 : (val: WasmF32) => String
55
+ ```
56
+
57
+ ### DebugPrint.**toStringF64**
58
+
59
+ ```grain
60
+ toStringF64 : (val: WasmF64) => String
29
61
  ```
30
62