@grain/stdlib 0.7.0 → 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.
- package/CHANGELOG.md +10 -0
- package/array.md +491 -491
- package/bigint.md +198 -198
- package/buffer.gr +66 -1
- package/buffer.md +395 -272
- package/bytes.gr +1 -0
- package/bytes.md +200 -199
- package/char.md +125 -125
- package/exception.md +9 -9
- package/float32.md +195 -195
- package/float64.md +195 -195
- package/fs.md +115 -115
- package/hash.md +16 -16
- package/int16.md +155 -155
- package/int32.gr +1 -1
- package/int32.md +207 -207
- package/int64.gr +1 -1
- package/int64.md +207 -207
- package/int8.md +155 -155
- package/json.md +59 -59
- package/list.md +347 -347
- package/map.md +222 -222
- package/marshal.md +12 -12
- package/number.gr +119 -5
- package/number.md +503 -261
- package/option.md +141 -141
- package/package.json +1 -1
- package/path.md +90 -90
- package/pervasives.md +238 -238
- package/priorityqueue.md +112 -112
- package/queue.md +117 -117
- package/random.md +37 -37
- package/range.md +36 -36
- package/rational.md +107 -107
- package/regex.md +91 -91
- package/result.md +102 -102
- package/runtime/atof/decimal.md +6 -6
- package/runtime/compare.md +7 -7
- package/runtime/dataStructures.md +178 -178
- package/runtime/equal.md +7 -7
- package/runtime/exception.md +15 -15
- package/runtime/malloc.md +9 -9
- package/runtime/numbers.md +269 -269
- package/runtime/string.md +17 -17
- package/runtime/unsafe/conv.md +6 -6
- package/runtime/unsafe/memory.md +10 -10
- package/runtime/utf8.md +31 -31
- package/runtime/wasi.md +9 -9
- package/set.md +211 -211
- package/stack.md +122 -122
- package/string.md +228 -228
- package/uint16.md +148 -148
- package/uint32.md +192 -192
- package/uint64.md +192 -192
- package/uint8.md +148 -148
- package/uri.md +77 -77
- package/wasi/file.md +269 -269
- package/wasi/process.md +21 -21
- package/wasi/random.md +9 -9
- package/wasi/time.md +12 -12
package/json.md
CHANGED
|
@@ -556,16 +556,16 @@ Converts the `Json` data structure into a JSON string with specific formatting s
|
|
|
556
556
|
|
|
557
557
|
Parameters:
|
|
558
558
|
|
|
559
|
-
|param|type|description|
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
559
|
+
| param | type | description |
|
|
560
|
+
| --------- | ------------------- | ------------------------------------ |
|
|
561
|
+
| `?format` | `FormattingChoices` | Formatting options |
|
|
562
|
+
| `json` | `Json` | The `Json` data structure to convert |
|
|
563
563
|
|
|
564
564
|
Returns:
|
|
565
565
|
|
|
566
|
-
|type|description|
|
|
567
|
-
|
|
568
|
-
|
|
566
|
+
| type | description |
|
|
567
|
+
| ----------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
|
|
568
|
+
| `Result<String, JsonToStringError>` | `Ok(str)` containing the JSON string or `Err(err)` if the provided `Json` data structure cannot be converted to a string |
|
|
569
569
|
|
|
570
570
|
Examples:
|
|
571
571
|
|
|
@@ -623,15 +623,15 @@ Parses JSON string into a `Json` data structure.
|
|
|
623
623
|
|
|
624
624
|
Parameters:
|
|
625
625
|
|
|
626
|
-
|param|type|description|
|
|
627
|
-
|
|
628
|
-
|
|
626
|
+
| param | type | description |
|
|
627
|
+
| ----- | -------- | ------------------------ |
|
|
628
|
+
| `str` | `String` | The JSON string to parse |
|
|
629
629
|
|
|
630
630
|
Returns:
|
|
631
631
|
|
|
632
|
-
|type|description|
|
|
633
|
-
|
|
634
|
-
|
|
632
|
+
| type | description |
|
|
633
|
+
| ------------------------------ | ---------------------------------------------------------------------------------------------------------------------- |
|
|
634
|
+
| `Result<Json, JsonParseError>` | `Ok(json)` containing the parsed data structure on a successful parse or `Err(err)` containing a parse error otherwise |
|
|
635
635
|
|
|
636
636
|
Examples:
|
|
637
637
|
|
|
@@ -687,10 +687,10 @@ data.
|
|
|
687
687
|
|
|
688
688
|
Fields:
|
|
689
689
|
|
|
690
|
-
|name|type|description|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
690
|
+
| name | type | description |
|
|
691
|
+
| ----- | ------------------------------------------- | ---------------------------------------------------------- |
|
|
692
|
+
| `get` | `(subject: a0) => Option<b0>` | A function which reads a value from the subject. |
|
|
693
|
+
| `set` | `(newValue: b0, subject: a0) => Option<a0>` | A function which immutably updates a value in the subject. |
|
|
694
694
|
|
|
695
695
|
### Values
|
|
696
696
|
|
|
@@ -706,16 +706,16 @@ Reads the value focused on by the given lens from the input data.
|
|
|
706
706
|
|
|
707
707
|
Parameters:
|
|
708
708
|
|
|
709
|
-
|param|type|description|
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
709
|
+
| param | type | description |
|
|
710
|
+
| --------- | ------------ | ----------------------------------------------- |
|
|
711
|
+
| `lens` | `Lens<a, b>` | The lens to apply to the subject data |
|
|
712
|
+
| `subject` | `a` | The data which will have the lens applied to it |
|
|
713
713
|
|
|
714
714
|
Returns:
|
|
715
715
|
|
|
716
|
-
|type|description|
|
|
717
|
-
|
|
718
|
-
|
|
716
|
+
| type | description |
|
|
717
|
+
| ----------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
|
|
718
|
+
| `Option<b>` | `Some(data)` containing the data read by the lens if the lens matches the given data, or `None` if the data cannot be matched to the lens |
|
|
719
719
|
|
|
720
720
|
Examples:
|
|
721
721
|
|
|
@@ -742,17 +742,17 @@ desired new value.
|
|
|
742
742
|
|
|
743
743
|
Parameters:
|
|
744
744
|
|
|
745
|
-
|param|type|description|
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
745
|
+
| param | type | description |
|
|
746
|
+
| ---------- | ------------ | ----------------------------------------------- |
|
|
747
|
+
| `lens` | `Lens<a, b>` | The lens to apply to the subject data |
|
|
748
|
+
| `newValue` | `b` | The new value to set at the focus of the lens |
|
|
749
|
+
| `subject` | `a` | The data which will have the lens applied to it |
|
|
750
750
|
|
|
751
751
|
Returns:
|
|
752
752
|
|
|
753
|
-
|type|description|
|
|
754
|
-
|
|
755
|
-
|
|
753
|
+
| type | description |
|
|
754
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
755
|
+
| `Option<a>` | `Some(data)` containing the new data after the lens substitution if the lens matches the given data, or `None` if the data cannot be matched to the lens |
|
|
756
756
|
|
|
757
757
|
Examples:
|
|
758
758
|
|
|
@@ -779,17 +779,17 @@ applying a function to it and setting the focus to the result of the function
|
|
|
779
779
|
|
|
780
780
|
Parameters:
|
|
781
781
|
|
|
782
|
-
|param|type|description|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
782
|
+
| param | type | description |
|
|
783
|
+
| --------- | ------------ | ---------------------------------------------------------------- |
|
|
784
|
+
| `lens` | `Lens<a, b>` | The lens to apply to the subject data |
|
|
785
|
+
| `fn` | `b => b` | The function to apply to the matched data at the lens if matched |
|
|
786
|
+
| `subject` | `a` | The data which will have the lens applied to it |
|
|
787
787
|
|
|
788
788
|
Returns:
|
|
789
789
|
|
|
790
|
-
|type|description|
|
|
791
|
-
|
|
792
|
-
|
|
790
|
+
| type | description |
|
|
791
|
+
| ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
792
|
+
| `Option<a>` | `Some(data)` containing the new data after the lens mapping has been applied if the lens matches the given data, or `None` if the data cannot be matched to the lens |
|
|
793
793
|
|
|
794
794
|
Examples:
|
|
795
795
|
|
|
@@ -935,15 +935,15 @@ Creates a lens whose focus is a given property of a JSON object.
|
|
|
935
935
|
|
|
936
936
|
Parameters:
|
|
937
937
|
|
|
938
|
-
|param|type|description|
|
|
939
|
-
|
|
940
|
-
|
|
938
|
+
| param | type | description |
|
|
939
|
+
| -------------- | -------- | ------------------------------------------------ |
|
|
940
|
+
| `propertyName` | `String` | The property name of the JSON object to focus on |
|
|
941
941
|
|
|
942
942
|
Returns:
|
|
943
943
|
|
|
944
|
-
|type|description|
|
|
945
|
-
|
|
946
|
-
|
|
944
|
+
| type | description |
|
|
945
|
+
| ------------------ | --------------------------------------------------------- |
|
|
946
|
+
| `Lens<Json, Json>` | A lens whose focus is the given property of a JSON object |
|
|
947
947
|
|
|
948
948
|
Examples:
|
|
949
949
|
|
|
@@ -1006,15 +1006,15 @@ Creates a lens whose focus is a given property path within a JSON object tree.
|
|
|
1006
1006
|
|
|
1007
1007
|
Parameters:
|
|
1008
1008
|
|
|
1009
|
-
|param|type|description|
|
|
1010
|
-
|
|
1011
|
-
|
|
1009
|
+
| param | type | description |
|
|
1010
|
+
| --------------- | -------------- | --------------------------------------------------------- |
|
|
1011
|
+
| `propertyNames` | `List<String>` | The property path of the JSON object to create a focus on |
|
|
1012
1012
|
|
|
1013
1013
|
Returns:
|
|
1014
1014
|
|
|
1015
|
-
|type|description|
|
|
1016
|
-
|
|
1017
|
-
|
|
1015
|
+
| type | description |
|
|
1016
|
+
| ------------------ | -------------------------------------------------------------- |
|
|
1017
|
+
| `Lens<Json, Json>` | A lens whose focus is the given property path of a JSON object |
|
|
1018
1018
|
|
|
1019
1019
|
Examples:
|
|
1020
1020
|
|
|
@@ -1038,16 +1038,16 @@ Reverse lens composition.
|
|
|
1038
1038
|
|
|
1039
1039
|
Parameters:
|
|
1040
1040
|
|
|
1041
|
-
|param|type|description|
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1041
|
+
| param | type | description |
|
|
1042
|
+
| ------- | ------------ | ------------------------------------- |
|
|
1043
|
+
| `lens1` | `Lens<a, b>` | The lens which will be applied first |
|
|
1044
|
+
| `lens2` | `Lens<b, c>` | The lens which will be applied second |
|
|
1045
1045
|
|
|
1046
1046
|
Returns:
|
|
1047
1047
|
|
|
1048
|
-
|type|description|
|
|
1049
|
-
|
|
1050
|
-
|
|
1048
|
+
| type | description |
|
|
1049
|
+
| ------------ | ----------------------------------------------------------------------------------------- |
|
|
1050
|
+
| `Lens<a, c>` | A lens which combines the two given lenses, passing through the first and then the second |
|
|
1051
1051
|
|
|
1052
1052
|
Examples:
|
|
1053
1053
|
|