@grain/stdlib 0.6.6 → 0.7.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 (137) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/array.gr +55 -7
  5. package/array.md +606 -560
  6. package/bigint.md +228 -228
  7. package/buffer.gr +85 -53
  8. package/buffer.md +442 -319
  9. package/bytes.gr +112 -35
  10. package/bytes.md +299 -219
  11. package/char.gr +201 -99
  12. package/char.md +447 -120
  13. package/exception.gr +11 -11
  14. package/exception.md +29 -4
  15. package/float32.gr +327 -3
  16. package/float32.md +698 -111
  17. package/float64.gr +320 -3
  18. package/float64.md +698 -111
  19. package/fs.gr +1082 -0
  20. package/fs.md +630 -0
  21. package/hash.gr +142 -88
  22. package/hash.md +105 -17
  23. package/int16.md +178 -178
  24. package/int32.gr +26 -5
  25. package/int32.md +266 -231
  26. package/int64.gr +27 -2
  27. package/int64.md +266 -231
  28. package/int8.md +178 -178
  29. package/json.gr +366 -51
  30. package/json.md +431 -15
  31. package/list.gr +328 -31
  32. package/list.md +759 -336
  33. package/map.gr +20 -12
  34. package/map.md +266 -260
  35. package/marshal.gr +41 -40
  36. package/marshal.md +14 -14
  37. package/number.gr +278 -35
  38. package/number.md +688 -269
  39. package/option.md +162 -162
  40. package/package.json +5 -3
  41. package/path.gr +48 -0
  42. package/path.md +180 -89
  43. package/pervasives.gr +2 -2
  44. package/pervasives.md +275 -275
  45. package/priorityqueue.gr +7 -7
  46. package/priorityqueue.md +131 -131
  47. package/queue.gr +183 -29
  48. package/queue.md +404 -148
  49. package/random.md +43 -43
  50. package/range.gr +4 -4
  51. package/range.md +42 -42
  52. package/rational.md +123 -123
  53. package/regex.gr +52 -51
  54. package/regex.md +102 -102
  55. package/result.md +118 -118
  56. package/runtime/atof/common.md +39 -39
  57. package/runtime/atof/decimal.gr +6 -6
  58. package/runtime/atof/decimal.md +14 -14
  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 +8 -8
  71. package/runtime/dataStructures.md +211 -211
  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 +8 -8
  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 +13 -13
  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 +348 -342
  98. package/runtime/string.gr +37 -105
  99. package/runtime/string.md +20 -26
  100. package/runtime/unsafe/constants.md +24 -24
  101. package/runtime/unsafe/conv.md +19 -19
  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 +147 -147
  117. package/set.gr +18 -11
  118. package/set.md +253 -247
  119. package/stack.gr +171 -2
  120. package/stack.md +371 -89
  121. package/string.gr +352 -557
  122. package/string.md +298 -255
  123. package/uint16.md +170 -170
  124. package/uint32.gr +25 -4
  125. package/uint32.md +249 -214
  126. package/uint64.gr +25 -5
  127. package/uint64.md +249 -214
  128. package/uint8.md +170 -170
  129. package/uri.gr +57 -53
  130. package/uri.md +88 -89
  131. package/wasi/file.gr +67 -59
  132. package/wasi/file.md +308 -308
  133. package/wasi/process.md +26 -26
  134. package/wasi/random.md +12 -12
  135. package/wasi/time.md +16 -16
  136. package/runtime/utils/printing.gr +0 -60
  137. package/runtime/utils/printing.md +0 -26
package/random.md CHANGED
@@ -35,22 +35,22 @@ No other changes yet.
35
35
  </details>
36
36
 
37
37
  ```grain
38
- make : (seed: Uint64) => Random
38
+ make: (seed: Uint64) => Random
39
39
  ```
40
40
 
41
41
  Creates a new pseudo-random number generator with the given seed.
42
42
 
43
43
  Parameters:
44
44
 
45
- |param|type|description|
46
- |-----|----|-----------|
47
- |`seed`|`Uint64`|The seed for the pseudo-random number generator|
45
+ | param | type | description |
46
+ | ------ | -------- | ----------------------------------------------- |
47
+ | `seed` | `Uint64` | The seed for the pseudo-random number generator |
48
48
 
49
49
  Returns:
50
50
 
51
- |type|description|
52
- |----|-----------|
53
- |`Random`|The pseudo-random number generator|
51
+ | type | description |
52
+ | -------- | ---------------------------------- |
53
+ | `Random` | The pseudo-random number generator |
54
54
 
55
55
  ### Random.**makeUnseeded**
56
56
 
@@ -60,16 +60,16 @@ No other changes yet.
60
60
  </details>
61
61
 
62
62
  ```grain
63
- makeUnseeded : () => Result<Random, Exception>
63
+ makeUnseeded: () => Result<Random, Exception>
64
64
  ```
65
65
 
66
66
  Creates a new pseudo-random number generator with a random seed.
67
67
 
68
68
  Returns:
69
69
 
70
- |type|description|
71
- |----|-----------|
72
- |`Result<Random, Exception>`|`Ok(generator)` of a pseudo-random number generator if successful or `Err(exception)` otherwise|
70
+ | type | description |
71
+ | --------------------------- | ----------------------------------------------------------------------------------------------- |
72
+ | `Result<Random, Exception>` | `Ok(generator)` of a pseudo-random number generator if successful or `Err(exception)` otherwise |
73
73
 
74
74
  ### Random.**nextUint32**
75
75
 
@@ -86,22 +86,22 @@ Returns:
86
86
  </details>
87
87
 
88
88
  ```grain
89
- nextUint32 : (random: Random) => Uint32
89
+ nextUint32: (random: Random) => Uint32
90
90
  ```
91
91
 
92
92
  Generates a random 32-bit integer from the given pseudo-random number generator.
93
93
 
94
94
  Parameters:
95
95
 
96
- |param|type|description|
97
- |-----|----|-----------|
98
- |`random`|`Random`|The pseudo-random number generator to use|
96
+ | param | type | description |
97
+ | -------- | -------- | ----------------------------------------- |
98
+ | `random` | `Random` | The pseudo-random number generator to use |
99
99
 
100
100
  Returns:
101
101
 
102
- |type|description|
103
- |----|-----------|
104
- |`Uint32`|The randomly generated number|
102
+ | type | description |
103
+ | -------- | ----------------------------- |
104
+ | `Uint32` | The randomly generated number |
105
105
 
106
106
  ### Random.**nextUint64**
107
107
 
@@ -118,22 +118,22 @@ Returns:
118
118
  </details>
119
119
 
120
120
  ```grain
121
- nextUint64 : (random: Random) => Uint64
121
+ nextUint64: (random: Random) => Uint64
122
122
  ```
123
123
 
124
124
  Generates a random 64-bit integer from the given pseudo-random number generator.
125
125
 
126
126
  Parameters:
127
127
 
128
- |param|type|description|
129
- |-----|----|-----------|
130
- |`random`|`Random`|The pseudo-random number generator to use|
128
+ | param | type | description |
129
+ | -------- | -------- | ----------------------------------------- |
130
+ | `random` | `Random` | The pseudo-random number generator to use |
131
131
 
132
132
  Returns:
133
133
 
134
- |type|description|
135
- |----|-----------|
136
- |`Uint64`|The randomly generated number|
134
+ | type | description |
135
+ | -------- | ----------------------------- |
136
+ | `Uint64` | The randomly generated number |
137
137
 
138
138
  ### Random.**nextUint32InRange**
139
139
 
@@ -150,7 +150,7 @@ Returns:
150
150
  </details>
151
151
 
152
152
  ```grain
153
- nextUint32InRange : (random: Random, low: Uint32, high: Uint32) => Uint32
153
+ nextUint32InRange: (random: Random, low: Uint32, high: Uint32) => Uint32
154
154
  ```
155
155
 
156
156
  Generates a random 32-bit integer from the given pseudo-random number generator
@@ -158,17 +158,17 @@ from a uniform distribution in the given range.
158
158
 
159
159
  Parameters:
160
160
 
161
- |param|type|description|
162
- |-----|----|-----------|
163
- |`random`|`Random`|The pseudo-random number generator to use|
164
- |`low`|`Uint32`|The lower bound of the range (inclusive)|
165
- |`high`|`Uint32`|The upper bound of the range (exclusive)|
161
+ | param | type | description |
162
+ | -------- | -------- | ----------------------------------------- |
163
+ | `random` | `Random` | The pseudo-random number generator to use |
164
+ | `low` | `Uint32` | The lower bound of the range (inclusive) |
165
+ | `high` | `Uint32` | The upper bound of the range (exclusive) |
166
166
 
167
167
  Returns:
168
168
 
169
- |type|description|
170
- |----|-----------|
171
- |`Uint32`|The randomly generated number|
169
+ | type | description |
170
+ | -------- | ----------------------------- |
171
+ | `Uint32` | The randomly generated number |
172
172
 
173
173
  ### Random.**nextUint64InRange**
174
174
 
@@ -185,7 +185,7 @@ Returns:
185
185
  </details>
186
186
 
187
187
  ```grain
188
- nextUint64InRange : (random: Random, low: Uint64, high: Uint64) => Uint64
188
+ nextUint64InRange: (random: Random, low: Uint64, high: Uint64) => Uint64
189
189
  ```
190
190
 
191
191
  Generates a random 64-bit integer from the given pseudo-random number generator
@@ -193,15 +193,15 @@ from a uniform distribution in the given range.
193
193
 
194
194
  Parameters:
195
195
 
196
- |param|type|description|
197
- |-----|----|-----------|
198
- |`random`|`Random`|The pseudo-random number generator to use|
199
- |`low`|`Uint64`|The lower bound of the range (inclusive)|
200
- |`high`|`Uint64`|The upper bound of the range (exclusive)|
196
+ | param | type | description |
197
+ | -------- | -------- | ----------------------------------------- |
198
+ | `random` | `Random` | The pseudo-random number generator to use |
199
+ | `low` | `Uint64` | The lower bound of the range (inclusive) |
200
+ | `high` | `Uint64` | The upper bound of the range (exclusive) |
201
201
 
202
202
  Returns:
203
203
 
204
- |type|description|
205
- |----|-----------|
206
- |`Uint64`|The randomly generated number|
204
+ | type | description |
205
+ | -------- | ----------------------------- |
206
+ | `Uint64` | The randomly generated number |
207
207
 
package/range.gr CHANGED
@@ -123,10 +123,10 @@ provide module Inclusive {
123
123
  */
124
124
  provide let inRange = (value, range) => {
125
125
  match (range) {
126
- { rangeStart: lower, rangeEnd: upper } when value >= lower &&
127
- value <= upper => true,
128
- { rangeStart: upper, rangeEnd: lower } when value >= lower &&
129
- value <= upper => true,
126
+ { rangeStart: lower, rangeEnd: upper } when value >= lower
127
+ && value <= upper => true,
128
+ { rangeStart: upper, rangeEnd: lower } when value >= lower
129
+ && value <= upper => true,
130
130
  _ => false,
131
131
  }
132
132
  }
package/range.md CHANGED
@@ -44,23 +44,23 @@ Functions and constants included in the Range module.
44
44
  </details>
45
45
 
46
46
  ```grain
47
- inRange : (value: Number, range: Range<Number>) => Bool
47
+ inRange: (value: Number, range: Range<Number>) => Bool
48
48
  ```
49
49
 
50
50
  Checks if the given number is within the range.
51
51
 
52
52
  Parameters:
53
53
 
54
- |param|type|description|
55
- |-----|----|-----------|
56
- |`value`|`Number`|The number being checked|
57
- |`range`|`Range<Number>`|The range to check within|
54
+ | param | type | description |
55
+ | ------- | --------------- | ------------------------- |
56
+ | `value` | `Number` | The number being checked |
57
+ | `range` | `Range<Number>` | The range to check within |
58
58
 
59
59
  Returns:
60
60
 
61
- |type|description|
62
- |----|-----------|
63
- |`Bool`|Whether or not the value is within range|
61
+ | type | description |
62
+ | ------ | ---------------------------------------- |
63
+ | `Bool` | Whether or not the value is within range |
64
64
 
65
65
  Examples:
66
66
 
@@ -87,7 +87,7 @@ Range.inRange(10, { rangeStart: 0, rangeEnd: 2 }) == false
87
87
  </details>
88
88
 
89
89
  ```grain
90
- forEach : (fn: (Number => Void), range: Range<Number>) => Void
90
+ forEach: (fn: (Number => Void), range: Range<Number>) => Void
91
91
  ```
92
92
 
93
93
  Calls the given function with each number in the range.
@@ -98,10 +98,10 @@ always changed by `1`, even if non-integer values were provided in the range.
98
98
 
99
99
  Parameters:
100
100
 
101
- |param|type|description|
102
- |-----|----|-----------|
103
- |`fn`|`Number => Void`|The function to be executed on each number in the range|
104
- |`range`|`Range<Number>`|The range to iterate|
101
+ | param | type | description |
102
+ | ------- | ---------------- | ------------------------------------------------------- |
103
+ | `fn` | `Number => Void` | The function to be executed on each number in the range |
104
+ | `range` | `Range<Number>` | The range to iterate |
105
105
 
106
106
  Examples:
107
107
 
@@ -124,7 +124,7 @@ Range.forEach(val => print(val), { rangeStart: 0, rangeEnd: 2 })
124
124
  </details>
125
125
 
126
126
  ```grain
127
- map : (fn: (Number => a), range: Range<Number>) => List<a>
127
+ map: (fn: (Number => a), range: Range<Number>) => List<a>
128
128
  ```
129
129
 
130
130
  Produces a list by calling the given function on each number included in the range.
@@ -135,16 +135,16 @@ always changed by `1`, even if non-integer values were provided in the range.
135
135
 
136
136
  Parameters:
137
137
 
138
- |param|type|description|
139
- |-----|----|-----------|
140
- |`fn`|`Number => a`|The function called on each number in the range that returns the value for the output list|
141
- |`range`|`Range<Number>`|The range to iterate|
138
+ | param | type | description |
139
+ | ------- | --------------- | ------------------------------------------------------------------------------------------ |
140
+ | `fn` | `Number => a` | The function called on each number in the range that returns the value for the output list |
141
+ | `range` | `Range<Number>` | The range to iterate |
142
142
 
143
143
  Returns:
144
144
 
145
- |type|description|
146
- |----|-----------|
147
- |`List<a>`|A list containing all values returned from the `fn`|
145
+ | type | description |
146
+ | --------- | --------------------------------------------------- |
147
+ | `List<a>` | A list containing all values returned from the `fn` |
148
148
 
149
149
  Examples:
150
150
 
@@ -173,23 +173,23 @@ Functions and constants included in the Range.Inclusive module.
173
173
  </details>
174
174
 
175
175
  ```grain
176
- inRange : (value: Number, range: Range<Number>) => Bool
176
+ inRange: (value: Number, range: Range<Number>) => Bool
177
177
  ```
178
178
 
179
179
  Checks if the given number is within the range.
180
180
 
181
181
  Parameters:
182
182
 
183
- |param|type|description|
184
- |-----|----|-----------|
185
- |`value`|`Number`|The number being checked|
186
- |`range`|`Range<Number>`|The range to check within|
183
+ | param | type | description |
184
+ | ------- | --------------- | ------------------------- |
185
+ | `value` | `Number` | The number being checked |
186
+ | `range` | `Range<Number>` | The range to check within |
187
187
 
188
188
  Returns:
189
189
 
190
- |type|description|
191
- |----|-----------|
192
- |`Bool`|Whether or not the value is within range|
190
+ | type | description |
191
+ | ------ | ---------------------------------------- |
192
+ | `Bool` | Whether or not the value is within range |
193
193
 
194
194
  Examples:
195
195
 
@@ -216,7 +216,7 @@ Range.Inclusive.inRange(10, { rangeStart: 0, rangeEnd: 2 }) == false
216
216
  </details>
217
217
 
218
218
  ```grain
219
- forEach : (fn: (Number => Void), range: Range<Number>) => Void
219
+ forEach: (fn: (Number => Void), range: Range<Number>) => Void
220
220
  ```
221
221
 
222
222
  Calls the given function with each number in the range.
@@ -227,10 +227,10 @@ always changed by `1`, even if non-integer values were provided in the range.
227
227
 
228
228
  Parameters:
229
229
 
230
- |param|type|description|
231
- |-----|----|-----------|
232
- |`fn`|`Number => Void`|The function to be executed on each number in the range|
233
- |`range`|`Range<Number>`|The range to iterate|
230
+ | param | type | description |
231
+ | ------- | ---------------- | ------------------------------------------------------- |
232
+ | `fn` | `Number => Void` | The function to be executed on each number in the range |
233
+ | `range` | `Range<Number>` | The range to iterate |
234
234
 
235
235
  Examples:
236
236
 
@@ -253,7 +253,7 @@ Range.Inclusive.forEach(val => print(val), { rangeStart: 0, rangeEnd: 2 })
253
253
  </details>
254
254
 
255
255
  ```grain
256
- map : (fn: (Number => a), range: Range<Number>) => List<a>
256
+ map: (fn: (Number => a), range: Range<Number>) => List<a>
257
257
  ```
258
258
 
259
259
  Produces a list by calling the given function on each number included in the range.
@@ -264,16 +264,16 @@ always changed by `1`, even if non-integer values were provided in the range.
264
264
 
265
265
  Parameters:
266
266
 
267
- |param|type|description|
268
- |-----|----|-----------|
269
- |`fn`|`Number => a`|The function called on each number in the range that returns the value for the output list|
270
- |`range`|`Range<Number>`|The range to iterate|
267
+ | param | type | description |
268
+ | ------- | --------------- | ------------------------------------------------------------------------------------------ |
269
+ | `fn` | `Number => a` | The function called on each number in the range that returns the value for the output list |
270
+ | `range` | `Range<Number>` | The range to iterate |
271
271
 
272
272
  Returns:
273
273
 
274
- |type|description|
275
- |----|-----------|
276
- |`List<a>`|A list containing all values returned from the `fn`|
274
+ | type | description |
275
+ | --------- | --------------------------------------------------- |
276
+ | `List<a>` | A list containing all values returned from the `fn` |
277
277
 
278
278
  Examples:
279
279