@grain/stdlib 0.5.12 → 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 +200 -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/path.md CHANGED
@@ -25,7 +25,7 @@ No other changes yet.
25
25
  </details>
26
26
 
27
27
  ```grain
28
- import Path from "path"
28
+ from "path" include Path
29
29
  ```
30
30
 
31
31
  ## Types
@@ -167,27 +167,37 @@ Represents possible errors for the `relativeTo` operation.
167
167
 
168
168
  ## Values
169
169
 
170
- Functions for working with Paths.
170
+ Functions and constants included in the Path module.
171
171
 
172
172
  ### Path.**fromString**
173
173
 
174
- <details disabled>
175
- <summary tabindex="-1">Added in <code>0.5.5</code></summary>
176
- No other changes yet.
174
+ <details>
175
+ <summary>Added in <code>0.5.5</code></summary>
176
+ <table>
177
+ <thead>
178
+ <tr><th>version</th><th>changes</th></tr>
179
+ </thead>
180
+ <tbody>
181
+ <tr><td><code>0.6.0</code></td><td>Merged with `fromPlatformString`; modified signature to accept platform</td></tr>
182
+ </tbody>
183
+ </table>
177
184
  </details>
178
185
 
179
186
  ```grain
180
- fromString : String -> Path
187
+ fromString : (pathStr: String, ?platform: Platform) => Path
181
188
  ```
182
189
 
183
- Parses a path string into a `Path`. Paths will be parsed as file paths
184
- rather than directory paths if there is ambiguity.
190
+ Parses a path string into a `Path` using the path separators appropriate to
191
+ the given platform (`/` for `Posix` and either `/` or `\` for `Windows`).
192
+ Paths will be parsed as file paths rather than directory paths if there is
193
+ ambiguity.
185
194
 
186
195
  Parameters:
187
196
 
188
197
  |param|type|description|
189
198
  |-----|----|-----------|
190
199
  |`pathStr`|`String`|The string to parse as a path|
200
+ |`?platform`|`Platform`|The platform whose path separators should be used for parsing|
191
201
 
192
202
  Returns:
193
203
 
@@ -197,10 +207,6 @@ Returns:
197
207
 
198
208
  Examples:
199
209
 
200
- ```grain
201
- fromString("/bin/") // an absolute Path referencing the directory /bin/
202
- ```
203
-
204
210
  ```grain
205
211
  fromString("file.txt") // a relative Path referencing the file ./file.txt
206
212
  ```
@@ -209,57 +215,34 @@ fromString("file.txt") // a relative Path referencing the file ./file.txt
209
215
  fromString(".") // a relative Path referencing the current directory
210
216
  ```
211
217
 
212
- ### Path.**fromPlatformString**
213
-
214
- <details disabled>
215
- <summary tabindex="-1">Added in <code>0.5.5</code></summary>
216
- No other changes yet.
217
- </details>
218
-
219
218
  ```grain
220
- fromPlatformString : (String, Platform) -> Path
219
+ fromString("/bin/", Posix) // an absolute Path referencing the directory /bin/
221
220
  ```
222
221
 
223
- Parses a path string into a `Path` using the path separators appropriate to
224
- the given platform (`/` for `Posix` and either `/` or `\` for `Windows`).
225
- Paths will be parsed as file paths rather than directory paths if there is
226
- ambiguity.
227
-
228
- Parameters:
229
-
230
- |param|type|description|
231
- |-----|----|-----------|
232
- |`pathStr`|`String`|The string to parse as a path|
233
- |`platform`|`Platform`|The platform whose path separators should be used for parsing|
234
-
235
- Returns:
236
-
237
- |type|description|
238
- |----|-----------|
239
- |`Path`|The path wrapped with details encoded within the type|
240
-
241
- Examples:
242
-
243
222
  ```grain
244
- fromPlatformString("/bin/", Posix) // an absolute Path referencing the directory /bin/
245
- ```
246
-
247
- ```grain
248
- fromPlatformString("C:\\file.txt", Windows) // a relative Path referencing the file C:\file.txt
223
+ fromString("C:\\file.txt", Windows) // a relative Path referencing the file C:\file.txt
249
224
  ```
250
225
 
251
226
  ### Path.**toString**
252
227
 
253
- <details disabled>
254
- <summary tabindex="-1">Added in <code>0.5.5</code></summary>
255
- No other changes yet.
228
+ <details>
229
+ <summary>Added in <code>0.5.5</code></summary>
230
+ <table>
231
+ <thead>
232
+ <tr><th>version</th><th>changes</th></tr>
233
+ </thead>
234
+ <tbody>
235
+ <tr><td><code>0.6.0</code></td><td>Merged with `toPlatformString`; modified signature to accept platform</td></tr>
236
+ </tbody>
237
+ </table>
256
238
  </details>
257
239
 
258
240
  ```grain
259
- toString : Path -> String
241
+ toString : (path: Path, ?platform: Platform) => String
260
242
  ```
261
243
 
262
- Converts the given `Path` into a string, using the `/` path separator.
244
+ Converts the given `Path` into a string, using the canonical path separator
245
+ appropriate to the given platform (`/` for `Posix` and `\` for `Windows`).
263
246
  A trailing slash is added to directory paths.
264
247
 
265
248
  Parameters:
@@ -267,6 +250,7 @@ Parameters:
267
250
  |param|type|description|
268
251
  |-----|----|-----------|
269
252
  |`path`|`Path`|The path to convert to a string|
253
+ |`?platform`|`Platform`|The `Platform` to use to represent the path as a string|
270
254
 
271
255
  Returns:
272
256
 
@@ -281,45 +265,11 @@ toString(fromString("/file.txt")) == "/file.txt"
281
265
  ```
282
266
 
283
267
  ```grain
284
- toString(fromString("dir/")) == "./dir/"
285
- ```
286
-
287
- ### Path.**toPlatformString**
288
-
289
- <details disabled>
290
- <summary tabindex="-1">Added in <code>0.5.5</code></summary>
291
- No other changes yet.
292
- </details>
293
-
294
- ```grain
295
- toPlatformString : (Path, Platform) -> String
296
- ```
297
-
298
- Converts the given `Path` into a string, using the canonical path separator
299
- appropriate to the given platform (`/` for `Posix` and `\` for `Windows`).
300
- A trailing slash is added to directory paths.
301
-
302
- Parameters:
303
-
304
- |param|type|description|
305
- |-----|----|-----------|
306
- |`path`|`Path`|The path to convert to a string|
307
- |`platform`|`Platform`|The `Platform` to use to represent the path as a string|
308
-
309
- Returns:
310
-
311
- |type|description|
312
- |----|-----------|
313
- |`String`|A string representing the given path|
314
-
315
- Examples:
316
-
317
- ```grain
318
- toPlatformString(fromString("dir/"), Posix) == "./dir/"
268
+ toString(fromString("dir/"), Posix) == "./dir/"
319
269
  ```
320
270
 
321
271
  ```grain
322
- toPlatformString(fromString("C:/file.txt"), Windows) == "C:\\file.txt"
272
+ toString(fromString("C:/file.txt"), Windows) == "C:\\file.txt"
323
273
  ```
324
274
 
325
275
  ### Path.**isDirectory**
@@ -330,7 +280,7 @@ No other changes yet.
330
280
  </details>
331
281
 
332
282
  ```grain
333
- isDirectory : Path -> Bool
283
+ isDirectory : (path: Path) => Bool
334
284
  ```
335
285
 
336
286
  Determines whether the path is a directory path.
@@ -360,7 +310,7 @@ isDirectory(fromString("/bin/")) == true
360
310
  ### Path.**isAbsolute**
361
311
 
362
312
  ```grain
363
- isAbsolute : Path -> Bool
313
+ isAbsolute : (path: Path) => Bool
364
314
  ```
365
315
 
366
316
  Determines whether the path is an absolute path.
@@ -395,7 +345,7 @@ No other changes yet.
395
345
  </details>
396
346
 
397
347
  ```grain
398
- append : (Path, Path) -> Result<Path, AppendError>
348
+ append : (path: Path, toAppend: Path) => Result<Path, AppendError>
399
349
  ```
400
350
 
401
351
  Creates a new path by appending a relative path segment to a directory path.
@@ -435,7 +385,7 @@ No other changes yet.
435
385
  </details>
436
386
 
437
387
  ```grain
438
- relativeTo : (Path, Path) -> Result<Path, RelativizationError>
388
+ relativeTo : (source: Path, dest: Path) => Result<Path, RelativizationError>
439
389
  ```
440
390
 
441
391
  Attempts to construct a new relative path which will lead to the destination
@@ -494,7 +444,8 @@ No other changes yet.
494
444
  </details>
495
445
 
496
446
  ```grain
497
- ancestry : (Path, Path) -> Result<AncestryStatus, IncompatibilityError>
447
+ ancestry :
448
+ (base: Path, path: Path) => Result<AncestryStatus, IncompatibilityError>
498
449
  ```
499
450
 
500
451
  Determines the relative ancestry betwen two paths.
@@ -538,7 +489,7 @@ No other changes yet.
538
489
  </details>
539
490
 
540
491
  ```grain
541
- parent : Path -> Path
492
+ parent : (path: Path) => Path
542
493
  ```
543
494
 
544
495
  Retrieves the path corresponding to the parent directory of the given path.
@@ -573,7 +524,7 @@ No other changes yet.
573
524
  </details>
574
525
 
575
526
  ```grain
576
- basename : Path -> Option<String>
527
+ basename : (path: Path) => Option<String>
577
528
  ```
578
529
 
579
530
  Retrieves the basename (named final segment) of a path.
@@ -608,7 +559,7 @@ No other changes yet.
608
559
  </details>
609
560
 
610
561
  ```grain
611
- stem : Path -> Result<String, PathOperationError>
562
+ stem : (path: Path) => Result<String, PathOperationError>
612
563
  ```
613
564
 
614
565
  Retrieves the basename of a file path without the extension.
@@ -651,7 +602,7 @@ No other changes yet.
651
602
  </details>
652
603
 
653
604
  ```grain
654
- extension : Path -> Result<String, PathOperationError>
605
+ extension : (path: Path) => Result<String, PathOperationError>
655
606
  ```
656
607
 
657
608
  Retrieves the extension on the basename of a file path.
@@ -694,7 +645,7 @@ No other changes yet.
694
645
  </details>
695
646
 
696
647
  ```grain
697
- root : Path -> Result<AbsoluteRoot, PathOperationError>
648
+ root : (path: Path) => Result<AbsoluteRoot, PathOperationError>
698
649
  ```
699
650
 
700
651
  Retrieves the root of the absolute path.