@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
package/option.gr CHANGED
@@ -1,19 +1,16 @@
1
1
  /**
2
- * @module Option: Utilities for working with the Option data type.
2
+ * Utilities for working with the Option data type.
3
3
  *
4
4
  * The Option type is an enum that represents the possibility of something being present (with the `Some` variant), or not (with the `None` variant). There’s no standalone `null` or `nil` type in Grain; use an Option where you would normally reach for `null` or `nil`.
5
5
  *
6
- * @example import Option from "option"
6
+ * @example from "option" include Option
7
7
  *
8
8
  * @example let hasValue = Some(1234) // Creates an Option containing 1234
9
9
  * @example let noValue = None // Creates an Option containing nothing
10
10
  *
11
11
  * @since v0.2.0
12
12
  */
13
-
14
- /**
15
- * @section Values: Functions for working with the Option data type.
16
- */
13
+ module Option
17
14
 
18
15
  /**
19
16
  * Checks if the Option is the `Some` variant.
@@ -23,7 +20,7 @@
23
20
  *
24
21
  * @since v0.2.0
25
22
  */
26
- export let isSome = option => {
23
+ provide let isSome = option => {
27
24
  match (option) {
28
25
  Some(_) => true,
29
26
  None => false,
@@ -38,7 +35,7 @@ export let isSome = option => {
38
35
  *
39
36
  * @since v0.2.0
40
37
  */
41
- export let isNone = option => {
38
+ provide let isNone = option => {
42
39
  match (option) {
43
40
  None => true,
44
41
  Some(_) => false,
@@ -54,7 +51,7 @@ export let isNone = option => {
54
51
  *
55
52
  * @since v0.2.0
56
53
  */
57
- export let contains = (value, option) => {
54
+ provide let contains = (value, option) => {
58
55
  match (option) {
59
56
  Some(x) => x == value,
60
57
  None => false,
@@ -73,7 +70,7 @@ export let contains = (value, option) => {
73
70
  *
74
71
  * @since v0.2.0
75
72
  */
76
- export let expect = (msg, option) => {
73
+ provide let expect = (msg, option) => {
77
74
  match (option) {
78
75
  Some(x) => x,
79
76
  None => fail msg,
@@ -91,7 +88,7 @@ export let expect = (msg, option) => {
91
88
  *
92
89
  * @since v0.2.0
93
90
  */
94
- export let unwrap = option => {
91
+ provide let unwrap = option => {
95
92
  expect("Could not unwrap None value", option)
96
93
  }
97
94
 
@@ -104,7 +101,7 @@ export let unwrap = option => {
104
101
  *
105
102
  * @since v0.2.0
106
103
  */
107
- export let unwrapWithDefault = (default, option) => {
104
+ provide let unwrapWithDefault = (default, option) => {
108
105
  match (option) {
109
106
  Some(x) => x,
110
107
  None => default,
@@ -120,7 +117,7 @@ export let unwrapWithDefault = (default, option) => {
120
117
  *
121
118
  * @since v0.2.0
122
119
  */
123
- export let map = (fn, option) => {
120
+ provide let map = (fn, option) => {
124
121
  match (option) {
125
122
  Some(x) => Some(fn(x)),
126
123
  None => None,
@@ -138,7 +135,7 @@ export let map = (fn, option) => {
138
135
  *
139
136
  * @since v0.2.0
140
137
  */
141
- export let mapWithDefault = (fn, default, option) => {
138
+ provide let mapWithDefault = (fn, default, option) => {
142
139
  match (option) {
143
140
  Some(x) => fn(x),
144
141
  None => default,
@@ -157,7 +154,7 @@ export let mapWithDefault = (fn, default, option) => {
157
154
  *
158
155
  * @since v0.2.0
159
156
  */
160
- export let mapWithDefaultFn = (fn, defaultFn, option) => {
157
+ provide let mapWithDefaultFn = (fn, defaultFn, option) => {
161
158
  match (option) {
162
159
  Some(x) => fn(x),
163
160
  None => defaultFn(),
@@ -173,7 +170,7 @@ export let mapWithDefaultFn = (fn, defaultFn, option) => {
173
170
  *
174
171
  * @since v0.2.0
175
172
  */
176
- export let flatMap = (fn, option) => {
173
+ provide let flatMap = (fn, option) => {
177
174
  match (option) {
178
175
  Some(x) => fn(x),
179
176
  None => None,
@@ -190,14 +187,13 @@ export let flatMap = (fn, option) => {
190
187
  *
191
188
  * @since v0.2.0
192
189
  */
193
- export let filter = (fn, option) => {
190
+ provide let filter = (fn, option) => {
194
191
  match (option) {
195
- Some(x) =>
196
- if (fn(x)) {
197
- Some(x)
198
- } else {
199
- None
200
- },
192
+ Some(x) => if (fn(x)) {
193
+ Some(x)
194
+ } else {
195
+ None
196
+ },
201
197
  None => None,
202
198
  }
203
199
  }
@@ -211,7 +207,7 @@ export let filter = (fn, option) => {
211
207
  *
212
208
  * @since v0.2.0
213
209
  */
214
- export let zip = (optionA, optionB) => {
210
+ provide let zip = (optionA, optionB) => {
215
211
  match ((optionA, optionB)) {
216
212
  (Some(a), Some(b)) => Some((a, b)),
217
213
  _ => None,
@@ -228,7 +224,7 @@ export let zip = (optionA, optionB) => {
228
224
  *
229
225
  * @since v0.2.0
230
226
  */
231
- export let zipWith = (fn, optionA, optionB) => {
227
+ provide let zipWith = (fn, optionA, optionB) => {
232
228
  match ((optionA, optionB)) {
233
229
  (Some(a), Some(b)) => Some(fn(a, b)),
234
230
  _ => None,
@@ -245,7 +241,7 @@ export let zipWith = (fn, optionA, optionB) => {
245
241
  *
246
242
  * @since v0.2.0
247
243
  */
248
- export let flatten = option => {
244
+ provide let flatten = option => {
249
245
  match (option) {
250
246
  Some(Some(x)) => Some(x),
251
247
  _ => None,
@@ -260,7 +256,7 @@ export let flatten = option => {
260
256
  *
261
257
  * @since v0.2.0
262
258
  */
263
- export let toList = option => {
259
+ provide let toList = option => {
264
260
  match (option) {
265
261
  Some(x) => [x],
266
262
  None => [],
@@ -275,7 +271,7 @@ export let toList = option => {
275
271
  *
276
272
  * @since v0.2.0
277
273
  */
278
- export let toArray = option => {
274
+ provide let toArray = option => {
279
275
  match (option) {
280
276
  Some(x) => [> x],
281
277
  None => [>],
@@ -291,7 +287,7 @@ export let toArray = option => {
291
287
  *
292
288
  * @since v0.2.0
293
289
  */
294
- export let toResult = (err, option) => {
290
+ provide let toResult = (err, option) => {
295
291
  match (option) {
296
292
  Some(a) => Ok(a),
297
293
  None => Err(err),
@@ -306,7 +302,7 @@ export let toResult = (err, option) => {
306
302
  *
307
303
  * @since v0.2.0
308
304
  */
309
- export let sideEffect = (fn, option) => {
305
+ provide let sideEffect = (fn, option) => {
310
306
  match (option) {
311
307
  Some(x) => fn(x),
312
308
  None => void,
@@ -323,7 +319,7 @@ export let sideEffect = (fn, option) => {
323
319
  *
324
320
  * @since v0.2.0
325
321
  */
326
- export let peek = (fn, option) => {
322
+ provide let peek = (fn, option) => {
327
323
  sideEffect(fn, option)
328
324
  option
329
325
  }
@@ -335,9 +331,10 @@ export let peek = (fn, option) => {
335
331
  * @param optionB: The second option
336
332
  * @returns The first Option if it is the `Some` variant or the second Option otherwise
337
333
  *
338
- * @since v0.2.0
334
+ * @since v0.6.0
335
+ * @history v0.2.0: Originally named `or`
339
336
  */
340
- export let or = (optionA, optionB) => {
337
+ provide let (||) = (optionA, optionB) => {
341
338
  match (optionA) {
342
339
  Some(x) => optionA,
343
340
  None => optionB,
@@ -351,9 +348,10 @@ export let or = (optionA, optionB) => {
351
348
  * @param optionB: The second option
352
349
  * @returns The second Option if both are the `Some` variant or the first Option otherwise
353
350
  *
354
- * @since v0.2.0
351
+ * @since v0.6.0
352
+ * @history v0.2.0: Originally named `and`
355
353
  */
356
- export let and = (optionA, optionB) => {
354
+ provide let (&&) = (optionA, optionB) => {
357
355
  match (optionA) {
358
356
  Some(_) => optionB,
359
357
  None => optionA,
package/option.md CHANGED
@@ -12,7 +12,7 @@ No other changes yet.
12
12
  </details>
13
13
 
14
14
  ```grain
15
- import Option from "option"
15
+ from "option" include Option
16
16
  ```
17
17
 
18
18
  ```grain
@@ -25,7 +25,7 @@ let noValue = None // Creates an Option containing nothing
25
25
 
26
26
  ## Values
27
27
 
28
- Functions for working with the Option data type.
28
+ Functions and constants included in the Option module.
29
29
 
30
30
  ### Option.**isSome**
31
31
 
@@ -35,7 +35,7 @@ No other changes yet.
35
35
  </details>
36
36
 
37
37
  ```grain
38
- isSome : Option<a> -> Bool
38
+ isSome : (option: Option<a>) => Bool
39
39
  ```
40
40
 
41
41
  Checks if the Option is the `Some` variant.
@@ -60,7 +60,7 @@ No other changes yet.
60
60
  </details>
61
61
 
62
62
  ```grain
63
- isNone : Option<a> -> Bool
63
+ isNone : (option: Option<a>) => Bool
64
64
  ```
65
65
 
66
66
  Checks if the Option is the `None` variant.
@@ -85,7 +85,7 @@ No other changes yet.
85
85
  </details>
86
86
 
87
87
  ```grain
88
- contains : (a, Option<a>) -> Bool
88
+ contains : (value: a, option: Option<a>) => Bool
89
89
  ```
90
90
 
91
91
  Checks if the Option is the `Some` variant and contains the given value. Uses the generic `==` equality operator.
@@ -111,7 +111,7 @@ No other changes yet.
111
111
  </details>
112
112
 
113
113
  ```grain
114
- expect : (String, Option<a>) -> a
114
+ expect : (msg: String, option: Option<a>) => a
115
115
  ```
116
116
 
117
117
  Extracts the value inside a `Some` option, otherwise throws an
@@ -144,7 +144,7 @@ No other changes yet.
144
144
  </details>
145
145
 
146
146
  ```grain
147
- unwrap : Option<a> -> a
147
+ unwrap : (option: Option<a>) => a
148
148
  ```
149
149
 
150
150
  Extracts the value inside a `Some` option, otherwise
@@ -176,7 +176,7 @@ No other changes yet.
176
176
  </details>
177
177
 
178
178
  ```grain
179
- unwrapWithDefault : (a, Option<a>) -> a
179
+ unwrapWithDefault : (default: a, option: Option<a>) => a
180
180
  ```
181
181
 
182
182
  Extracts the value inside a `Some` option or provide the default value if `None`.
@@ -202,7 +202,7 @@ No other changes yet.
202
202
  </details>
203
203
 
204
204
  ```grain
205
- map : ((a -> b), Option<a>) -> Option<b>
205
+ map : (fn: (a => b), option: Option<a>) => Option<b>
206
206
  ```
207
207
 
208
208
  If the Option is `Some(value)`, applies the given function to the `value` and wraps the new value in a `Some` variant.
@@ -211,7 +211,7 @@ Parameters:
211
211
 
212
212
  |param|type|description|
213
213
  |-----|----|-----------|
214
- |`fn`|`a -> b`|The function to call on the value of a `Some` variant|
214
+ |`fn`|`a => b`|The function to call on the value of a `Some` variant|
215
215
  |`option`|`Option<a>`|The option to map|
216
216
 
217
217
  Returns:
@@ -228,7 +228,7 @@ No other changes yet.
228
228
  </details>
229
229
 
230
230
  ```grain
231
- mapWithDefault : ((a -> b), b, Option<a>) -> b
231
+ mapWithDefault : (fn: (a => b), default: b, option: Option<a>) => b
232
232
  ```
233
233
 
234
234
  If the Option is `Some(value)`, applies the given function to the `value` to produce a new value, otherwise uses the default value.
@@ -238,7 +238,7 @@ Parameters:
238
238
 
239
239
  |param|type|description|
240
240
  |-----|----|-----------|
241
- |`fn`|`a -> b`|The function to call on the value of a `Some` variant|
241
+ |`fn`|`a => b`|The function to call on the value of a `Some` variant|
242
242
  |`default`|`b`|A fallback value for a `None` variant|
243
243
  |`option`|`Option<a>`|The option to map|
244
244
 
@@ -256,7 +256,8 @@ No other changes yet.
256
256
  </details>
257
257
 
258
258
  ```grain
259
- mapWithDefaultFn : ((a -> b), (() -> b), Option<a>) -> b
259
+ mapWithDefaultFn :
260
+ (fn: (a => b), defaultFn: (() => b), option: Option<a>) => b
260
261
  ```
261
262
 
262
263
  If the Option is `Some(value)`, applies the `fn` function to the `value` to produce a new value.
@@ -267,8 +268,8 @@ Parameters:
267
268
 
268
269
  |param|type|description|
269
270
  |-----|----|-----------|
270
- |`fn`|`a -> b`|The function to call on the value of a `Some` variant|
271
- |`defaultFn`|`() -> b`|The default function|
271
+ |`fn`|`a => b`|The function to call on the value of a `Some` variant|
272
+ |`defaultFn`|`() => b`|The default function|
272
273
  |`option`|`Option<a>`|The option to map|
273
274
 
274
275
  Returns:
@@ -285,7 +286,7 @@ No other changes yet.
285
286
  </details>
286
287
 
287
288
  ```grain
288
- flatMap : ((a -> Option<b>), Option<a>) -> Option<b>
289
+ flatMap : (fn: (a => Option<b>), option: Option<a>) => Option<b>
289
290
  ```
290
291
 
291
292
  If the Option is `Some(value)`, applies the given function to the `value` to produce a new Option.
@@ -294,7 +295,7 @@ Parameters:
294
295
 
295
296
  |param|type|description|
296
297
  |-----|----|-----------|
297
- |`fn`|`a -> Option<b>`|The function to call on the value of a `Some` variant|
298
+ |`fn`|`a => Option<b>`|The function to call on the value of a `Some` variant|
298
299
  |`option`|`Option<a>`|The option to map|
299
300
 
300
301
  Returns:
@@ -311,7 +312,7 @@ No other changes yet.
311
312
  </details>
312
313
 
313
314
  ```grain
314
- filter : ((a -> Bool), Option<a>) -> Option<a>
315
+ filter : (fn: (a => Bool), option: Option<a>) => Option<a>
315
316
  ```
316
317
 
317
318
  Converts `Some(value)` variants to `None` variants where the predicate function returns `false`.
@@ -321,7 +322,7 @@ Parameters:
321
322
 
322
323
  |param|type|description|
323
324
  |-----|----|-----------|
324
- |`fn`|`a -> Bool`|The predicate function to indicate if the option should remain `Some`|
325
+ |`fn`|`a => Bool`|The predicate function to indicate if the option should remain `Some`|
325
326
  |`option`|`Option<a>`|The option to inspect|
326
327
 
327
328
  Returns:
@@ -338,7 +339,7 @@ No other changes yet.
338
339
  </details>
339
340
 
340
341
  ```grain
341
- zip : (Option<a>, Option<b>) -> Option<(a, b)>
342
+ zip : (optionA: Option<a>, optionB: Option<b>) => Option<(a, b)>
342
343
  ```
343
344
 
344
345
  Combine two Options into a single Option containing a tuple of their values.
@@ -364,7 +365,8 @@ No other changes yet.
364
365
  </details>
365
366
 
366
367
  ```grain
367
- zipWith : (((a, b) -> c), Option<a>, Option<b>) -> Option<c>
368
+ zipWith :
369
+ (fn: ((a, b) => c), optionA: Option<a>, optionB: Option<b>) => Option<c>
368
370
  ```
369
371
 
370
372
  Combine two Options into a single Option. The new value is produced by applying the given function to both values.
@@ -373,7 +375,7 @@ Parameters:
373
375
 
374
376
  |param|type|description|
375
377
  |-----|----|-----------|
376
- |`fn`|`(a, b) -> c`|The function to generate a new value|
378
+ |`fn`|`(a, b) => c`|The function to generate a new value|
377
379
  |`optionA`|`Option<a>`|The first option to combine|
378
380
  |`optionB`|`Option<b>`|The second option to combine|
379
381
 
@@ -391,7 +393,7 @@ No other changes yet.
391
393
  </details>
392
394
 
393
395
  ```grain
394
- flatten : Option<Option<a>> -> Option<a>
396
+ flatten : (option: Option<Option<a>>) => Option<a>
395
397
  ```
396
398
 
397
399
  Flattens nested Options.
@@ -422,7 +424,7 @@ No other changes yet.
422
424
  </details>
423
425
 
424
426
  ```grain
425
- toList : Option<a> -> List<a>
427
+ toList : (option: Option<a>) => List<a>
426
428
  ```
427
429
 
428
430
  Converts an Option to a list with either zero or one item.
@@ -447,7 +449,7 @@ No other changes yet.
447
449
  </details>
448
450
 
449
451
  ```grain
450
- toArray : Option<a> -> Array<a>
452
+ toArray : (option: Option<a>) => Array<a>
451
453
  ```
452
454
 
453
455
  Converts an Option to an array with either zero or one item.
@@ -472,7 +474,7 @@ No other changes yet.
472
474
  </details>
473
475
 
474
476
  ```grain
475
- toResult : (a, Option<b>) -> Result<b, a>
477
+ toResult : (err: a, option: Option<b>) => Result<b, a>
476
478
  ```
477
479
 
478
480
  Converts the Option to a Result, using the provided error in case of the `None` variant.
@@ -498,7 +500,7 @@ No other changes yet.
498
500
  </details>
499
501
 
500
502
  ```grain
501
- sideEffect : ((a -> Void), Option<a>) -> Void
503
+ sideEffect : (fn: (a => Void), option: Option<a>) => Void
502
504
  ```
503
505
 
504
506
  If the Option is `Some(value)`, applies the `fn` function to the `value` without producing a new value.
@@ -507,7 +509,7 @@ Parameters:
507
509
 
508
510
  |param|type|description|
509
511
  |-----|----|-----------|
510
- |`fn`|`a -> Void`|The function to call on the value of a `Some` variant|
512
+ |`fn`|`a => Void`|The function to call on the value of a `Some` variant|
511
513
  |`option`|`Option<a>`|The option to inspect|
512
514
 
513
515
  ### Option.**peek**
@@ -518,7 +520,7 @@ No other changes yet.
518
520
  </details>
519
521
 
520
522
  ```grain
521
- peek : ((a -> Void), Option<a>) -> Option<a>
523
+ peek : (fn: (a => Void), option: Option<a>) => Option<a>
522
524
  ```
523
525
 
524
526
  If the Option is `Some(value)`, applies the `fn` function to the `value` without producing a new value.
@@ -528,7 +530,7 @@ Parameters:
528
530
 
529
531
  |param|type|description|
530
532
  |-----|----|-----------|
531
- |`fn`|`a -> Void`|The function to call on the value of a `Some` variant|
533
+ |`fn`|`a => Void`|The function to call on the value of a `Some` variant|
532
534
  |`option`|`Option<a>`|The option to inspect|
533
535
 
534
536
  Returns:
@@ -537,15 +539,22 @@ Returns:
537
539
  |----|-----------|
538
540
  |`Option<a>`|The unmodified option|
539
541
 
540
- ### Option.**or**
541
-
542
- <details disabled>
543
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
544
- No other changes yet.
542
+ ### Option.**(||)**
543
+
544
+ <details>
545
+ <summary>Added in <code>0.6.0</code></summary>
546
+ <table>
547
+ <thead>
548
+ <tr><th>version</th><th>changes</th></tr>
549
+ </thead>
550
+ <tbody>
551
+ <tr><td><code>0.2.0</code></td><td>Originally named `or`</td></tr>
552
+ </tbody>
553
+ </table>
545
554
  </details>
546
555
 
547
556
  ```grain
548
- or : (Option<a>, Option<a>) -> Option<a>
557
+ (||) : (optionA: Option<a>, optionB: Option<a>) => Option<a>
549
558
  ```
550
559
 
551
560
  Behaves like a logical OR (`||`) where the first Option is only returned if it is the `Some` variant and falling back to the second Option in all other cases.
@@ -563,15 +572,22 @@ Returns:
563
572
  |----|-----------|
564
573
  |`Option<a>`|The first Option if it is the `Some` variant or the second Option otherwise|
565
574
 
566
- ### Option.**and**
567
-
568
- <details disabled>
569
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
570
- No other changes yet.
575
+ ### Option.**(&&)**
576
+
577
+ <details>
578
+ <summary>Added in <code>0.6.0</code></summary>
579
+ <table>
580
+ <thead>
581
+ <tr><th>version</th><th>changes</th></tr>
582
+ </thead>
583
+ <tbody>
584
+ <tr><td><code>0.2.0</code></td><td>Originally named `and`</td></tr>
585
+ </tbody>
586
+ </table>
571
587
  </details>
572
588
 
573
589
  ```grain
574
- and : (Option<a>, Option<a>) -> Option<a>
590
+ (&&) : (optionA: Option<a>, optionB: Option<a>) => Option<a>
575
591
  ```
576
592
 
577
593
  Behaves like a logical AND (`&&`) where the first Option is only returned if it is the `None` variant and falling back to the second Option Result in all other cases.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@grain/stdlib",
3
- "version": "0.5.13",
3
+ "version": "0.6.1",
4
4
  "description": "The standard library for the Grain language.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://grain-lang.org",
@@ -18,7 +18,7 @@
18
18
  "directory": "stdlib"
19
19
  },
20
20
  "engines": {
21
- "node": ">=16"
21
+ "node": ">=18.15"
22
22
  },
23
23
  "main": "index.js",
24
24
  "files": [