@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/set.md CHANGED
@@ -4,13 +4,15 @@ title: Set
4
4
 
5
5
  A Set is an unordered collection of unique values. Operations on a Set mutate the internal state, so it never needs to be re-assigned.
6
6
 
7
+ An immutable set implementation is available in the `Immutable` submodule.
8
+
7
9
  <details disabled>
8
10
  <summary tabindex="-1">Added in <code>0.3.0</code></summary>
9
11
  No other changes yet.
10
12
  </details>
11
13
 
12
14
  ```grain
13
- import Set from "set"
15
+ from "set" include Set
14
16
  ```
15
17
 
16
18
  ## Types
@@ -23,28 +25,49 @@ Type declarations included in the Set module.
23
25
  type Set<k>
24
26
  ```
25
27
 
28
+ ### Set.**InternalSetStats**
29
+
30
+ ```grain
31
+ record InternalSetStats {
32
+ currentSize: Number,
33
+ bucketCount: Number,
34
+ }
35
+ ```
36
+
37
+ Represents the internal state of a set.
38
+
26
39
  ## Values
27
40
 
28
- Functions for working with Sets.
41
+ Functions and constants included in the Set module.
29
42
 
30
- ### Set.**makeSized**
43
+ ### Set.**make**
31
44
 
32
- <details disabled>
33
- <summary tabindex="-1">Added in <code>0.3.0</code></summary>
34
- No other changes yet.
45
+ <details>
46
+ <summary>Added in <code>0.3.0</code></summary>
47
+ <table>
48
+ <thead>
49
+ <tr><th>version</th><th>changes</th></tr>
50
+ </thead>
51
+ <tbody>
52
+ <tr><td><code>0.6.0</code></td><td>Merged with `makeSized`; modified signature to accept size</td></tr>
53
+ </tbody>
54
+ </table>
35
55
  </details>
36
56
 
37
57
  ```grain
38
- makeSized : Number -> Set<a>
58
+ make : (?size: Number) => Set<a>
39
59
  ```
40
60
 
41
- Creates a new empty set with an initial storage of the given size. As values are added or removed, the internal storage may grow or shrink. Generally, you won't need to care about the storage size of your set and can use `Set.make()` instead.
61
+ Creates a new empty set with an initial storage of the given size. As
62
+ values are added or removed, the internal storage may grow or shrink.
63
+ Generally, you won't need to care about the storage size of your set and
64
+ can use the default size.
42
65
 
43
66
  Parameters:
44
67
 
45
68
  |param|type|description|
46
69
  |-----|----|-----------|
47
- |`size`|`Number`|The initial storage size of the set|
70
+ |`?size`|`Number`|The initial storage size of the set|
48
71
 
49
72
  Returns:
50
73
 
@@ -52,25 +75,6 @@ Returns:
52
75
  |----|-----------|
53
76
  |`Set<a>`|An empty set with the given initial storage size|
54
77
 
55
- ### Set.**make**
56
-
57
- <details disabled>
58
- <summary tabindex="-1">Added in <code>0.3.0</code></summary>
59
- No other changes yet.
60
- </details>
61
-
62
- ```grain
63
- make : () -> Set<a>
64
- ```
65
-
66
- Creates a new, empty set.
67
-
68
- Returns:
69
-
70
- |type|description|
71
- |----|-----------|
72
- |`Set<a>`|An empty set|
73
-
74
78
  ### Set.**add**
75
79
 
76
80
  <details disabled>
@@ -79,7 +83,7 @@ No other changes yet.
79
83
  </details>
80
84
 
81
85
  ```grain
82
- add : (a, Set<a>) -> Void
86
+ add : (key: a, set: Set<a>) => Void
83
87
  ```
84
88
 
85
89
  Adds a new value to the set. If the value already exists, nothing happens.
@@ -99,7 +103,7 @@ No other changes yet.
99
103
  </details>
100
104
 
101
105
  ```grain
102
- contains : (a, Set<a>) -> Bool
106
+ contains : (key: a, set: Set<a>) => Bool
103
107
  ```
104
108
 
105
109
  Determines if the set contains the given value.
@@ -125,7 +129,7 @@ No other changes yet.
125
129
  </details>
126
130
 
127
131
  ```grain
128
- remove : (a, Set<a>) -> Void
132
+ remove : (key: a, set: Set<a>) => Void
129
133
  ```
130
134
 
131
135
  Removes the given value from the set. If the value doesn't exist, nothing happens.
@@ -145,7 +149,7 @@ No other changes yet.
145
149
  </details>
146
150
 
147
151
  ```grain
148
- size : Set<a> -> Number
152
+ size : (set: Set<a>) => Number
149
153
  ```
150
154
 
151
155
  Provides the count of values within the set.
@@ -170,7 +174,7 @@ No other changes yet.
170
174
  </details>
171
175
 
172
176
  ```grain
173
- isEmpty : Set<a> -> Bool
177
+ isEmpty : (set: Set<a>) => Bool
174
178
  ```
175
179
 
176
180
  Determines if the set contains no elements.
@@ -195,7 +199,7 @@ No other changes yet.
195
199
  </details>
196
200
 
197
201
  ```grain
198
- clear : Set<a> -> Void
202
+ clear : (set: Set<a>) => Void
199
203
  ```
200
204
 
201
205
  Resets the set by removing all values.
@@ -221,7 +225,7 @@ Parameters:
221
225
  </details>
222
226
 
223
227
  ```grain
224
- forEach : ((a -> Void), Set<a>) -> Void
228
+ forEach : (fn: (a => Void), set: Set<a>) => Void
225
229
  ```
226
230
 
227
231
  Iterates the set, calling an iterator function on each element.
@@ -230,7 +234,7 @@ Parameters:
230
234
 
231
235
  |param|type|description|
232
236
  |-----|----|-----------|
233
- |`fn`|`a -> Void`|The iterator function to call with each element|
237
+ |`fn`|`a => Void`|The iterator function to call with each element|
234
238
  |`set`|`Set<a>`|The set to iterate|
235
239
 
236
240
  ### Set.**reduce**
@@ -241,7 +245,7 @@ No other changes yet.
241
245
  </details>
242
246
 
243
247
  ```grain
244
- reduce : (((a, b) -> a), a, Set<b>) -> a
248
+ reduce : (fn: ((a, b) => a), init: a, set: Set<b>) => a
245
249
  ```
246
250
 
247
251
  Combines all elements of a set using a reducer function.
@@ -250,7 +254,7 @@ Parameters:
250
254
 
251
255
  |param|type|description|
252
256
  |-----|----|-----------|
253
- |`fn`|`(a, b) -> a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
257
+ |`fn`|`(a, b) => a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
254
258
  |`init`|`a`|The initial value to use for the accumulator on the first iteration|
255
259
  |`set`|`Set<b>`|The set to iterate|
256
260
 
@@ -268,7 +272,7 @@ No other changes yet.
268
272
  </details>
269
273
 
270
274
  ```grain
271
- filter : ((a -> Bool), Set<a>) -> Void
275
+ filter : (fn: (a => Bool), set: Set<a>) => Void
272
276
  ```
273
277
 
274
278
  Removes elements from a set where a predicate function returns `false`.
@@ -277,7 +281,7 @@ Parameters:
277
281
 
278
282
  |param|type|description|
279
283
  |-----|----|-----------|
280
- |`fn`|`a -> Bool`|The predicate function to indicate which elements to remove from the set, where returning `false` indicates the value should be removed|
284
+ |`fn`|`a => Bool`|The predicate function to indicate which elements to remove from the set, where returning `false` indicates the value should be removed|
281
285
  |`set`|`Set<a>`|The set to iterate|
282
286
 
283
287
  ### Set.**reject**
@@ -288,7 +292,7 @@ No other changes yet.
288
292
  </details>
289
293
 
290
294
  ```grain
291
- reject : ((a -> Bool), Set<a>) -> Void
295
+ reject : (fn: (a => Bool), set: Set<a>) => Void
292
296
  ```
293
297
 
294
298
  Removes elements from a set where a predicate function returns `true`.
@@ -297,7 +301,7 @@ Parameters:
297
301
 
298
302
  |param|type|description|
299
303
  |-----|----|-----------|
300
- |`fn`|`a -> Bool`|The predicate function to indicate which elements to remove from the set, where returning `true` indicates the value should be removed|
304
+ |`fn`|`a => Bool`|The predicate function to indicate which elements to remove from the set, where returning `true` indicates the value should be removed|
301
305
  |`set`|`Set<a>`|The set to iterate|
302
306
 
303
307
  ### Set.**toList**
@@ -308,7 +312,7 @@ No other changes yet.
308
312
  </details>
309
313
 
310
314
  ```grain
311
- toList : Set<a> -> List<a>
315
+ toList : (set: Set<a>) => List<a>
312
316
  ```
313
317
 
314
318
  Converts a set into a list of its elements.
@@ -333,7 +337,7 @@ No other changes yet.
333
337
  </details>
334
338
 
335
339
  ```grain
336
- fromList : List<a> -> Set<a>
340
+ fromList : (list: List<a>) => Set<a>
337
341
  ```
338
342
 
339
343
  Creates a set from a list.
@@ -358,7 +362,7 @@ No other changes yet.
358
362
  </details>
359
363
 
360
364
  ```grain
361
- toArray : Set<a> -> Array<a>
365
+ toArray : (set: Set<a>) => Array<a>
362
366
  ```
363
367
 
364
368
  Converts a set into an array of its elements.
@@ -383,7 +387,7 @@ No other changes yet.
383
387
  </details>
384
388
 
385
389
  ```grain
386
- fromArray : Array<a> -> Set<a>
390
+ fromArray : (array: Array<a>) => Set<a>
387
391
  ```
388
392
 
389
393
  Creates a set from an array.
@@ -408,7 +412,7 @@ No other changes yet.
408
412
  </details>
409
413
 
410
414
  ```grain
411
- union : (Set<a>, Set<a>) -> Set<a>
415
+ union : (set1: Set<a>, set2: Set<a>) => Set<a>
412
416
  ```
413
417
 
414
418
  Combines two sets into a single set containing all elements from both sets.
@@ -434,7 +438,7 @@ No other changes yet.
434
438
  </details>
435
439
 
436
440
  ```grain
437
- diff : (Set<a>, Set<a>) -> Set<a>
441
+ diff : (set1: Set<a>, set2: Set<a>) => Set<a>
438
442
  ```
439
443
 
440
444
  Combines two sets into a single set containing only the elements not shared between both sets.
@@ -460,7 +464,7 @@ No other changes yet.
460
464
  </details>
461
465
 
462
466
  ```grain
463
- intersect : (Set<a>, Set<a>) -> Set<a>
467
+ intersect : (set1: Set<a>, set2: Set<a>) => Set<a>
464
468
  ```
465
469
 
466
470
  Combines two sets into a single set containing only the elements shared between both sets.
@@ -480,13 +484,20 @@ Returns:
480
484
 
481
485
  ### Set.**getInternalStats**
482
486
 
483
- <details disabled>
484
- <summary tabindex="-1">Added in <code>0.3.0</code></summary>
485
- No other changes yet.
487
+ <details>
488
+ <summary>Added in <code>0.3.0</code></summary>
489
+ <table>
490
+ <thead>
491
+ <tr><th>version</th><th>changes</th></tr>
492
+ </thead>
493
+ <tbody>
494
+ <tr><td><code>0.6.0</code></td><td>Return `InternalSetStats` record instead of a tuple</td></tr>
495
+ </tbody>
496
+ </table>
486
497
  </details>
487
498
 
488
499
  ```grain
489
- getInternalStats : Set<a> -> (Number, Number)
500
+ getInternalStats : (set: Set<a>) => InternalSetStats
490
501
  ```
491
502
 
492
503
  Provides data representing the internal state state of the set.
@@ -501,5 +512,574 @@ Returns:
501
512
 
502
513
  |type|description|
503
514
  |----|-----------|
504
- |`(Number, Number)`|The internal state of the set|
515
+ |`InternalSetStats`|The internal state of the set|
516
+
517
+ ## Set.Immutable
518
+
519
+ An immutable set implementation.
520
+
521
+ <details>
522
+ <summary>Added in <code>0.6.0</code></summary>
523
+ <table>
524
+ <thead>
525
+ <tr><th>version</th><th>changes</th></tr>
526
+ </thead>
527
+ <tbody>
528
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
529
+ </tbody>
530
+ </table>
531
+ </details>
532
+
533
+ ### Types
534
+
535
+ Type declarations included in the Set.Immutable module.
536
+
537
+ #### Set.Immutable.**Set**
538
+
539
+ ```grain
540
+ type Set<a>
541
+ ```
542
+
543
+ ### Values
544
+
545
+ Functions and constants included in the Set.Immutable module.
546
+
547
+ #### Set.Immutable.**empty**
548
+
549
+ <details>
550
+ <summary>Added in <code>0.6.0</code></summary>
551
+ <table>
552
+ <thead>
553
+ <tr><th>version</th><th>changes</th></tr>
554
+ </thead>
555
+ <tbody>
556
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
557
+ </tbody>
558
+ </table>
559
+ </details>
560
+
561
+ ```grain
562
+ empty : Set<a>
563
+ ```
564
+
565
+ An empty set
566
+
567
+ #### Set.Immutable.**size**
568
+
569
+ <details>
570
+ <summary>Added in <code>0.6.0</code></summary>
571
+ <table>
572
+ <thead>
573
+ <tr><th>version</th><th>changes</th></tr>
574
+ </thead>
575
+ <tbody>
576
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
577
+ </tbody>
578
+ </table>
579
+ </details>
580
+
581
+ ```grain
582
+ size : (set: Set<a>) => Number
583
+ ```
584
+
585
+ Provides the count of values within the set.
586
+
587
+ Parameters:
588
+
589
+ |param|type|description|
590
+ |-----|----|-----------|
591
+ |`set`|`Set<a>`|The set to inspect|
592
+
593
+ Returns:
594
+
595
+ |type|description|
596
+ |----|-----------|
597
+ |`Number`|The count of elements in the set|
598
+
599
+ #### Set.Immutable.**isEmpty**
600
+
601
+ <details>
602
+ <summary>Added in <code>0.6.0</code></summary>
603
+ <table>
604
+ <thead>
605
+ <tr><th>version</th><th>changes</th></tr>
606
+ </thead>
607
+ <tbody>
608
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
609
+ </tbody>
610
+ </table>
611
+ </details>
612
+
613
+ ```grain
614
+ isEmpty : (set: Set<a>) => Bool
615
+ ```
616
+
617
+ Determines if the set contains no elements.
618
+
619
+ Parameters:
620
+
621
+ |param|type|description|
622
+ |-----|----|-----------|
623
+ |`set`|`Set<a>`|The set to inspect|
624
+
625
+ Returns:
626
+
627
+ |type|description|
628
+ |----|-----------|
629
+ |`Bool`|`true` if the given set is empty or `false` otherwise|
630
+
631
+ #### Set.Immutable.**add**
632
+
633
+ <details>
634
+ <summary>Added in <code>0.6.0</code></summary>
635
+ <table>
636
+ <thead>
637
+ <tr><th>version</th><th>changes</th></tr>
638
+ </thead>
639
+ <tbody>
640
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
641
+ </tbody>
642
+ </table>
643
+ </details>
644
+
645
+ ```grain
646
+ add : (key: a, set: Set<a>) => Set<a>
647
+ ```
648
+
649
+ Produces a new set by inserting the given value into the set. If the value
650
+ already exists, the new set will have the same elements as the input set.
651
+
652
+ Parameters:
653
+
654
+ |param|type|description|
655
+ |-----|----|-----------|
656
+ |`key`|`a`|The value to add|
657
+ |`set`|`Set<a>`|The base set|
658
+
659
+ Returns:
660
+
661
+ |type|description|
662
+ |----|-----------|
663
+ |`Set<a>`|A new set containing the new element|
664
+
665
+ #### Set.Immutable.**contains**
666
+
667
+ <details>
668
+ <summary>Added in <code>0.6.0</code></summary>
669
+ <table>
670
+ <thead>
671
+ <tr><th>version</th><th>changes</th></tr>
672
+ </thead>
673
+ <tbody>
674
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
675
+ </tbody>
676
+ </table>
677
+ </details>
678
+
679
+ ```grain
680
+ contains : (key: a, set: Set<a>) => Bool
681
+ ```
682
+
683
+ Determines if the set contains the given value.
684
+
685
+ Parameters:
686
+
687
+ |param|type|description|
688
+ |-----|----|-----------|
689
+ |`key`|`a`|The value to search for|
690
+ |`set`|`Set<a>`|The set to search|
691
+
692
+ Returns:
693
+
694
+ |type|description|
695
+ |----|-----------|
696
+ |`Bool`|`true` if the set contains the given value or `false` otherwise|
697
+
698
+ #### Set.Immutable.**remove**
699
+
700
+ <details>
701
+ <summary>Added in <code>0.6.0</code></summary>
702
+ <table>
703
+ <thead>
704
+ <tr><th>version</th><th>changes</th></tr>
705
+ </thead>
706
+ <tbody>
707
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
708
+ </tbody>
709
+ </table>
710
+ </details>
711
+
712
+ ```grain
713
+ remove : (key: a, set: Set<a>) => Set<a>
714
+ ```
715
+
716
+ Produces a new set without the given element. If the value doesn't exist in
717
+ the set, the set will be returned unmodified.
718
+
719
+ Parameters:
720
+
721
+ |param|type|description|
722
+ |-----|----|-----------|
723
+ |`key`|`a`|The value to exclude|
724
+ |`set`|`Set<a>`|The set to exclude from|
725
+
726
+ Returns:
727
+
728
+ |type|description|
729
+ |----|-----------|
730
+ |`Set<a>`|A new set without the excluded element|
731
+
732
+ #### Set.Immutable.**forEach**
733
+
734
+ <details>
735
+ <summary>Added in <code>0.6.0</code></summary>
736
+ <table>
737
+ <thead>
738
+ <tr><th>version</th><th>changes</th></tr>
739
+ </thead>
740
+ <tbody>
741
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
742
+ </tbody>
743
+ </table>
744
+ </details>
745
+
746
+ ```grain
747
+ forEach : (fn: (a => Void), set: Set<a>) => Void
748
+ ```
749
+
750
+ Iterates the set, calling an iterator function on each element.
751
+
752
+ Parameters:
753
+
754
+ |param|type|description|
755
+ |-----|----|-----------|
756
+ |`fn`|`a => Void`|The iterator function to call with each element|
757
+ |`set`|`Set<a>`|The set to iterate|
758
+
759
+ #### Set.Immutable.**reduce**
760
+
761
+ <details>
762
+ <summary>Added in <code>0.6.0</code></summary>
763
+ <table>
764
+ <thead>
765
+ <tr><th>version</th><th>changes</th></tr>
766
+ </thead>
767
+ <tbody>
768
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
769
+ </tbody>
770
+ </table>
771
+ </details>
772
+
773
+ ```grain
774
+ reduce : (fn: ((a, b) => a), init: a, set: Set<b>) => a
775
+ ```
776
+
777
+ Combines all elements of a set using a reducer function.
778
+
779
+ Parameters:
780
+
781
+ |param|type|description|
782
+ |-----|----|-----------|
783
+ |`fn`|`(a, b) => a`|The reducer function to call on each element, where the value returned will be the next accumulator value|
784
+ |`init`|`a`|The initial value to use for the accumulator on the first iteration|
785
+ |`set`|`Set<b>`|The set to iterate|
786
+
787
+ Returns:
788
+
789
+ |type|description|
790
+ |----|-----------|
791
+ |`a`|The final accumulator returned from `fn`|
792
+
793
+ #### Set.Immutable.**filter**
794
+
795
+ <details>
796
+ <summary>Added in <code>0.6.0</code></summary>
797
+ <table>
798
+ <thead>
799
+ <tr><th>version</th><th>changes</th></tr>
800
+ </thead>
801
+ <tbody>
802
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
803
+ </tbody>
804
+ </table>
805
+ </details>
806
+
807
+ ```grain
808
+ filter : (fn: (a => Bool), set: Set<a>) => Set<a>
809
+ ```
810
+
811
+ Produces a new set without the elements from the input set where a predicate function returns `false`.
812
+
813
+ Parameters:
814
+
815
+ |param|type|description|
816
+ |-----|----|-----------|
817
+ |`fn`|`a => Bool`|The predicate function to indicate which elements to exclude from the set, where returning `false` indicates the value should be excluded|
818
+ |`set`|`Set<a>`|The set to iterate|
819
+
820
+ Returns:
821
+
822
+ |type|description|
823
+ |----|-----------|
824
+ |`Set<a>`|A new set excluding the elements not fulfilling the predicate|
825
+
826
+ #### Set.Immutable.**reject**
827
+
828
+ <details>
829
+ <summary>Added in <code>0.6.0</code></summary>
830
+ <table>
831
+ <thead>
832
+ <tr><th>version</th><th>changes</th></tr>
833
+ </thead>
834
+ <tbody>
835
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
836
+ </tbody>
837
+ </table>
838
+ </details>
839
+
840
+ ```grain
841
+ reject : (fn: (a => Bool), set: Set<a>) => Set<a>
842
+ ```
843
+
844
+ Produces a new set without the elements from the input set where a predicate function returns `true`.
845
+
846
+ Parameters:
847
+
848
+ |param|type|description|
849
+ |-----|----|-----------|
850
+ |`fn`|`a => Bool`|The predicate function to indicate which elements to exclude from the set, where returning `true` indicates the value should be excluded|
851
+ |`set`|`Set<a>`|The set to iterate|
852
+
853
+ Returns:
854
+
855
+ |type|description|
856
+ |----|-----------|
857
+ |`Set<a>`|A new set excluding the elements fulfilling the predicate|
858
+
859
+ #### Set.Immutable.**union**
860
+
861
+ <details>
862
+ <summary>Added in <code>0.6.0</code></summary>
863
+ <table>
864
+ <thead>
865
+ <tr><th>version</th><th>changes</th></tr>
866
+ </thead>
867
+ <tbody>
868
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
869
+ </tbody>
870
+ </table>
871
+ </details>
872
+
873
+ ```grain
874
+ union : (set1: Set<a>, set2: Set<a>) => Set<a>
875
+ ```
876
+
877
+ Combines two sets into a single set containing all elements from both sets.
878
+
879
+ Parameters:
880
+
881
+ |param|type|description|
882
+ |-----|----|-----------|
883
+ |`set1`|`Set<a>`|The first set to combine|
884
+ |`set2`|`Set<a>`|The second set to combine|
885
+
886
+ Returns:
887
+
888
+ |type|description|
889
+ |----|-----------|
890
+ |`Set<a>`|A set containing all elements of both sets|
891
+
892
+ #### Set.Immutable.**diff**
893
+
894
+ <details>
895
+ <summary>Added in <code>0.6.0</code></summary>
896
+ <table>
897
+ <thead>
898
+ <tr><th>version</th><th>changes</th></tr>
899
+ </thead>
900
+ <tbody>
901
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
902
+ </tbody>
903
+ </table>
904
+ </details>
905
+
906
+ ```grain
907
+ diff : (set1: Set<a>, set2: Set<a>) => Set<a>
908
+ ```
909
+
910
+ Combines two sets into a single set containing only the elements not shared between both sets.
911
+
912
+ Parameters:
913
+
914
+ |param|type|description|
915
+ |-----|----|-----------|
916
+ |`set1`|`Set<a>`|The first set to combine|
917
+ |`set2`|`Set<a>`|The second set to combine|
918
+
919
+ Returns:
920
+
921
+ |type|description|
922
+ |----|-----------|
923
+ |`Set<a>`|A set containing only unshared elements from both sets|
924
+
925
+ #### Set.Immutable.**intersect**
926
+
927
+ <details>
928
+ <summary>Added in <code>0.6.0</code></summary>
929
+ <table>
930
+ <thead>
931
+ <tr><th>version</th><th>changes</th></tr>
932
+ </thead>
933
+ <tbody>
934
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
935
+ </tbody>
936
+ </table>
937
+ </details>
938
+
939
+ ```grain
940
+ intersect : (set1: Set<a>, set2: Set<a>) => Set<a>
941
+ ```
942
+
943
+ Combines two sets into a single set containing only the elements shared between both sets.
944
+
945
+ Parameters:
946
+
947
+ |param|type|description|
948
+ |-----|----|-----------|
949
+ |`set1`|`Set<a>`|The first set to combine|
950
+ |`set2`|`Set<a>`|The second set to combine|
951
+
952
+ Returns:
953
+
954
+ |type|description|
955
+ |----|-----------|
956
+ |`Set<a>`|A set containing only shared elements from both sets|
957
+
958
+ #### Set.Immutable.**fromList**
959
+
960
+ <details>
961
+ <summary>Added in <code>0.6.0</code></summary>
962
+ <table>
963
+ <thead>
964
+ <tr><th>version</th><th>changes</th></tr>
965
+ </thead>
966
+ <tbody>
967
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
968
+ </tbody>
969
+ </table>
970
+ </details>
971
+
972
+ ```grain
973
+ fromList : (list: List<a>) => Set<a>
974
+ ```
975
+
976
+ Creates a set from a list.
977
+
978
+ Parameters:
979
+
980
+ |param|type|description|
981
+ |-----|----|-----------|
982
+ |`list`|`List<a>`|The list to convert|
983
+
984
+ Returns:
985
+
986
+ |type|description|
987
+ |----|-----------|
988
+ |`Set<a>`|A set containing all list values|
989
+
990
+ #### Set.Immutable.**toList**
991
+
992
+ <details>
993
+ <summary>Added in <code>0.6.0</code></summary>
994
+ <table>
995
+ <thead>
996
+ <tr><th>version</th><th>changes</th></tr>
997
+ </thead>
998
+ <tbody>
999
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
1000
+ </tbody>
1001
+ </table>
1002
+ </details>
1003
+
1004
+ ```grain
1005
+ toList : (set: Set<a>) => List<a>
1006
+ ```
1007
+
1008
+ Converts a set into a list of its elements.
1009
+
1010
+ Parameters:
1011
+
1012
+ |param|type|description|
1013
+ |-----|----|-----------|
1014
+ |`set`|`Set<a>`|The set to convert|
1015
+
1016
+ Returns:
1017
+
1018
+ |type|description|
1019
+ |----|-----------|
1020
+ |`List<a>`|A list containing all set values|
1021
+
1022
+ #### Set.Immutable.**fromArray**
1023
+
1024
+ <details>
1025
+ <summary>Added in <code>0.6.0</code></summary>
1026
+ <table>
1027
+ <thead>
1028
+ <tr><th>version</th><th>changes</th></tr>
1029
+ </thead>
1030
+ <tbody>
1031
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
1032
+ </tbody>
1033
+ </table>
1034
+ </details>
1035
+
1036
+ ```grain
1037
+ fromArray : (array: Array<a>) => Set<a>
1038
+ ```
1039
+
1040
+ Creates a set from an array.
1041
+
1042
+ Parameters:
1043
+
1044
+ |param|type|description|
1045
+ |-----|----|-----------|
1046
+ |`array`|`Array<a>`|The array to convert|
1047
+
1048
+ Returns:
1049
+
1050
+ |type|description|
1051
+ |----|-----------|
1052
+ |`Set<a>`|A set containing all array values|
1053
+
1054
+ #### Set.Immutable.**toArray**
1055
+
1056
+ <details>
1057
+ <summary>Added in <code>0.6.0</code></summary>
1058
+ <table>
1059
+ <thead>
1060
+ <tr><th>version</th><th>changes</th></tr>
1061
+ </thead>
1062
+ <tbody>
1063
+ <tr><td><code>0.5.4</code></td><td>Originally in `"immutableset"` module</td></tr>
1064
+ </tbody>
1065
+ </table>
1066
+ </details>
1067
+
1068
+ ```grain
1069
+ toArray : (set: Set<a>) => Array<a>
1070
+ ```
1071
+
1072
+ Converts a set into an array of its elements.
1073
+
1074
+ Parameters:
1075
+
1076
+ |param|type|description|
1077
+ |-----|----|-----------|
1078
+ |`set`|`Set<a>`|The set to convert|
1079
+
1080
+ Returns:
1081
+
1082
+ |type|description|
1083
+ |----|-----------|
1084
+ |`Array<a>`|An array containing all set values|
505
1085