@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.
Files changed (155) hide show
  1. package/CHANGELOG.md +193 -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 +47 -37
  21. package/hash.md +21 -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 +2084 -0
  31. package/json.md +608 -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 +191 -172
  92. package/runtime/numberUtils.md +17 -9
  93. package/runtime/numbers.gr +1695 -1021
  94. package/runtime/numbers.md +1098 -134
  95. package/runtime/string.gr +540 -242
  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
package/immutablemap.md DELETED
@@ -1,479 +0,0 @@
1
- ---
2
- title: ImmutableMap
3
- ---
4
-
5
- An ImmutableMap holds key-value pairs. Any value may be used as a key or value. Operations on an ImmutableMap do not mutate the map's internal state.
6
-
7
- <details disabled>
8
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
9
- No other changes yet.
10
- </details>
11
-
12
- ```grain
13
- import ImmutableMap from "immutablemap"
14
- ```
15
-
16
- ## Types
17
-
18
- Type declarations included in the ImmutableMap module.
19
-
20
- ### ImmutableMap.**ImmutableMap**
21
-
22
- ```grain
23
- type ImmutableMap<k, v>
24
- ```
25
-
26
- ## Values
27
-
28
- Functions and constants for working with ImmutableMaps.
29
-
30
- ### ImmutableMap.**empty**
31
-
32
- <details disabled>
33
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
34
- No other changes yet.
35
- </details>
36
-
37
- ```grain
38
- empty : ImmutableMap<a, b>
39
- ```
40
-
41
- An empty map
42
-
43
- ### ImmutableMap.**size**
44
-
45
- <details disabled>
46
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
47
- No other changes yet.
48
- </details>
49
-
50
- ```grain
51
- size : ImmutableMap<a, b> -> Number
52
- ```
53
-
54
- Provides the count of key-value pairs stored within the map.
55
-
56
- Parameters:
57
-
58
- |param|type|description|
59
- |-----|----|-----------|
60
- |`map`|`ImmutableMap<a, b>`|The map to inspect|
61
-
62
- Returns:
63
-
64
- |type|description|
65
- |----|-----------|
66
- |`Number`|The count of key-value pairs in the map|
67
-
68
- ### ImmutableMap.**isEmpty**
69
-
70
- <details disabled>
71
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
72
- No other changes yet.
73
- </details>
74
-
75
- ```grain
76
- isEmpty : ImmutableMap<a, b> -> Bool
77
- ```
78
-
79
- Determines if the map contains no key-value pairs.
80
-
81
- Parameters:
82
-
83
- |param|type|description|
84
- |-----|----|-----------|
85
- |`map`|`ImmutableMap<a, b>`|The map to inspect|
86
-
87
- Returns:
88
-
89
- |type|description|
90
- |----|-----------|
91
- |`Bool`|`true` if the given map is empty or `false` otherwise|
92
-
93
- ### ImmutableMap.**set**
94
-
95
- <details disabled>
96
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
97
- No other changes yet.
98
- </details>
99
-
100
- ```grain
101
- set : (a, b, ImmutableMap<a, b>) -> ImmutableMap<a, b>
102
- ```
103
-
104
- Produces a new map containing a new key-value pair. If the key already exists in the map, the value is replaced.
105
-
106
- Parameters:
107
-
108
- |param|type|description|
109
- |-----|----|-----------|
110
- |`key`|`a`|The unique key in the map|
111
- |`value`|`b`|The value to store|
112
- |`map`|`ImmutableMap<a, b>`|The base map|
113
-
114
- Returns:
115
-
116
- |type|description|
117
- |----|-----------|
118
- |`ImmutableMap<a, b>`|A new map containing the new key-value pair|
119
-
120
- ### ImmutableMap.**get**
121
-
122
- <details disabled>
123
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
124
- No other changes yet.
125
- </details>
126
-
127
- ```grain
128
- get : (a, ImmutableMap<a, b>) -> Option<b>
129
- ```
130
-
131
- Retrieves the value for the given key.
132
-
133
- Parameters:
134
-
135
- |param|type|description|
136
- |-----|----|-----------|
137
- |`key`|`a`|The key to access|
138
- |`map`|`ImmutableMap<a, b>`|The map to access|
139
-
140
- Returns:
141
-
142
- |type|description|
143
- |----|-----------|
144
- |`Option<b>`|`Some(value)` if the key exists in the map or `None` otherwise|
145
-
146
- ### ImmutableMap.**contains**
147
-
148
- <details disabled>
149
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
150
- No other changes yet.
151
- </details>
152
-
153
- ```grain
154
- contains : (a, ImmutableMap<a, b>) -> Bool
155
- ```
156
-
157
- Determines if the map contains the given key. In such a case, it will always contain a value for the given key.
158
-
159
- Parameters:
160
-
161
- |param|type|description|
162
- |-----|----|-----------|
163
- |`key`|`a`|The key to search for|
164
- |`map`|`ImmutableMap<a, b>`|The map to search|
165
-
166
- Returns:
167
-
168
- |type|description|
169
- |----|-----------|
170
- |`Bool`|`true` if the map contains the given key or `false` otherwise|
171
-
172
- ### ImmutableMap.**remove**
173
-
174
- <details disabled>
175
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
176
- No other changes yet.
177
- </details>
178
-
179
- ```grain
180
- remove : (a, ImmutableMap<a, b>) -> ImmutableMap<a, b>
181
- ```
182
-
183
- Produces a new map without the key-value pair corresponding to the given
184
- key. If the key doesn't exist in the map, the map will be returned unmodified.
185
-
186
- Parameters:
187
-
188
- |param|type|description|
189
- |-----|----|-----------|
190
- |`key`|`a`|The key to exclude|
191
- |`map`|`ImmutableMap<a, b>`|The map to exclude from|
192
-
193
- Returns:
194
-
195
- |type|description|
196
- |----|-----------|
197
- |`ImmutableMap<a, b>`|A new map without the given key|
198
-
199
- ### ImmutableMap.**update**
200
-
201
- <details disabled>
202
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
203
- No other changes yet.
204
- </details>
205
-
206
- ```grain
207
- update :
208
- (a, (Option<b> -> Option<b>), ImmutableMap<a, b>) -> ImmutableMap<a, b>
209
- ```
210
-
211
- Produces a new map by calling an updater function that receives the
212
- previously stored value as an `Option` and returns the new value to be
213
- stored as an `Option`. If the key didn't exist previously, the value
214
- will be `None`. If `None` is returned from the updater function, the
215
- key-value pair is excluded.
216
-
217
- Parameters:
218
-
219
- |param|type|description|
220
- |-----|----|-----------|
221
- |`key`|`a`|The unique key in the map|
222
- |`fn`|`Option<b> -> Option<b>`|The updater function|
223
- |`map`|`ImmutableMap<a, b>`|The base map|
224
-
225
- Returns:
226
-
227
- |type|description|
228
- |----|-----------|
229
- |`ImmutableMap<a, b>`|A new map with the value at the given key modified according to the function's output|
230
-
231
- ### ImmutableMap.**forEach**
232
-
233
- <details disabled>
234
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
235
- No other changes yet.
236
- </details>
237
-
238
- ```grain
239
- forEach : (((a, b) -> Void), ImmutableMap<a, b>) -> Void
240
- ```
241
-
242
- Iterates the map, calling an iterator function with each key and value.
243
-
244
- Parameters:
245
-
246
- |param|type|description|
247
- |-----|----|-----------|
248
- |`fn`|`(a, b) -> Void`|The iterator function to call with each key and value|
249
- |`map`|`ImmutableMap<a, b>`|The map to iterate|
250
-
251
- ### ImmutableMap.**reduce**
252
-
253
- <details disabled>
254
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
255
- No other changes yet.
256
- </details>
257
-
258
- ```grain
259
- reduce : (((a, b, c) -> a), a, ImmutableMap<b, c>) -> a
260
- ```
261
-
262
- Combines all key-value pairs of a map using a reducer function.
263
-
264
- Parameters:
265
-
266
- |param|type|description|
267
- |-----|----|-----------|
268
- |`fn`|`(a, b, c) -> a`|The reducer function to call on each key and value, where the value returned will be the next accumulator value|
269
- |`init`|`a`|The initial value to use for the accumulator on the first iteration|
270
- |`map`|`ImmutableMap<b, c>`|The map to iterate|
271
-
272
- Returns:
273
-
274
- |type|description|
275
- |----|-----------|
276
- |`a`|The final accumulator returned from `fn`|
277
-
278
- ### ImmutableMap.**keys**
279
-
280
- <details disabled>
281
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
282
- No other changes yet.
283
- </details>
284
-
285
- ```grain
286
- keys : ImmutableMap<a, b> -> List<a>
287
- ```
288
-
289
- Enumerates all keys in the given map.
290
-
291
- Parameters:
292
-
293
- |param|type|description|
294
- |-----|----|-----------|
295
- |`map`|`ImmutableMap<a, b>`|The map to enumerate|
296
-
297
- Returns:
298
-
299
- |type|description|
300
- |----|-----------|
301
- |`List<a>`|A list containing all keys from the given map|
302
-
303
- ### ImmutableMap.**values**
304
-
305
- <details disabled>
306
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
307
- No other changes yet.
308
- </details>
309
-
310
- ```grain
311
- values : ImmutableMap<a, b> -> List<b>
312
- ```
313
-
314
- Enumerates all values in the given map.
315
-
316
- Parameters:
317
-
318
- |param|type|description|
319
- |-----|----|-----------|
320
- |`map`|`ImmutableMap<a, b>`|The map to enumerate|
321
-
322
- Returns:
323
-
324
- |type|description|
325
- |----|-----------|
326
- |`List<b>`|A list containing all values from the given map|
327
-
328
- ### ImmutableMap.**filter**
329
-
330
- <details disabled>
331
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
332
- No other changes yet.
333
- </details>
334
-
335
- ```grain
336
- filter : (((a, b) -> Bool), ImmutableMap<a, b>) -> ImmutableMap<a, b>
337
- ```
338
-
339
- Produces a new map excluding the key-value pairs where a predicate function returns `false`.
340
-
341
- Parameters:
342
-
343
- |param|type|description|
344
- |-----|----|-----------|
345
- |`fn`|`(a, b) -> Bool`|The predicate function to indicate which key-value pairs to exclude from the map, where returning `false` indicates the key-value pair should be excluded|
346
- |`map`|`ImmutableMap<a, b>`|The map to iterate|
347
-
348
- Returns:
349
-
350
- |type|description|
351
- |----|-----------|
352
- |`ImmutableMap<a, b>`|A new map excluding the key-value pairs not fulfilling the predicate|
353
-
354
- ### ImmutableMap.**reject**
355
-
356
- <details disabled>
357
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
358
- No other changes yet.
359
- </details>
360
-
361
- ```grain
362
- reject : (((a, b) -> Bool), ImmutableMap<a, b>) -> ImmutableMap<a, b>
363
- ```
364
-
365
- Produces a new map excluding the key-value pairs where a predicate function returns `true`.
366
-
367
- Parameters:
368
-
369
- |param|type|description|
370
- |-----|----|-----------|
371
- |`fn`|`(a, b) -> Bool`|The predicate function to indicate which key-value pairs to exclude from the map, where returning `true` indicates the key-value pair should be excluded|
372
- |`map`|`ImmutableMap<a, b>`|The map to iterate|
373
-
374
- Returns:
375
-
376
- |type|description|
377
- |----|-----------|
378
- |`ImmutableMap<a, b>`|A new map excluding the key-value pairs fulfilling the predicate|
379
-
380
- ### ImmutableMap.**fromList**
381
-
382
- <details disabled>
383
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
384
- No other changes yet.
385
- </details>
386
-
387
- ```grain
388
- fromList : List<(a, b)> -> ImmutableMap<a, b>
389
- ```
390
-
391
- Creates a map from a list.
392
-
393
- Parameters:
394
-
395
- |param|type|description|
396
- |-----|----|-----------|
397
- |`list`|`List<(a, b)>`|The list to convert|
398
-
399
- Returns:
400
-
401
- |type|description|
402
- |----|-----------|
403
- |`ImmutableMap<a, b>`|A map containing all key-value pairs from the list|
404
-
405
- ### ImmutableMap.**toList**
406
-
407
- <details disabled>
408
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
409
- No other changes yet.
410
- </details>
411
-
412
- ```grain
413
- toList : ImmutableMap<a, b> -> List<(a, b)>
414
- ```
415
-
416
- Enumerates all key-value pairs in the given map.
417
-
418
- Parameters:
419
-
420
- |param|type|description|
421
- |-----|----|-----------|
422
- |`map`|`ImmutableMap<a, b>`|The map to enumerate|
423
-
424
- Returns:
425
-
426
- |type|description|
427
- |----|-----------|
428
- |`List<(a, b)>`|A list containing all key-value pairs from the given map|
429
-
430
- ### ImmutableMap.**fromArray**
431
-
432
- <details disabled>
433
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
434
- No other changes yet.
435
- </details>
436
-
437
- ```grain
438
- fromArray : Array<(a, b)> -> ImmutableMap<a, b>
439
- ```
440
-
441
- Creates a map from an array.
442
-
443
- Parameters:
444
-
445
- |param|type|description|
446
- |-----|----|-----------|
447
- |`array`|`Array<(a, b)>`|The array to convert|
448
-
449
- Returns:
450
-
451
- |type|description|
452
- |----|-----------|
453
- |`ImmutableMap<a, b>`|A map containing all key-value pairs from the array|
454
-
455
- ### ImmutableMap.**toArray**
456
-
457
- <details disabled>
458
- <summary tabindex="-1">Added in <code>0.5.4</code></summary>
459
- No other changes yet.
460
- </details>
461
-
462
- ```grain
463
- toArray : ImmutableMap<a, b> -> Array<(a, b)>
464
- ```
465
-
466
- Converts a map into an array of its key-value pairs.
467
-
468
- Parameters:
469
-
470
- |param|type|description|
471
- |-----|----|-----------|
472
- |`map`|`ImmutableMap<a, b>`|The map to convert|
473
-
474
- Returns:
475
-
476
- |type|description|
477
- |----|-----------|
478
- |`Array<(a, b)>`|An array containing all key-value pairs from the given map|
479
-