@grain/stdlib 0.4.1 → 0.4.5

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 (57) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/LICENSE +21 -0
  3. package/README.md +34 -0
  4. package/array.gr +200 -89
  5. package/array.md +81 -5
  6. package/buffer.gr +93 -36
  7. package/bytes.gr +512 -407
  8. package/bytes.md +621 -0
  9. package/char.gr +119 -55
  10. package/char.md +200 -0
  11. package/hash.gr +42 -15
  12. package/hash.md +44 -0
  13. package/list.gr +121 -50
  14. package/map.gr +106 -110
  15. package/number.gr +37 -1
  16. package/number.md +66 -0
  17. package/option.gr +260 -53
  18. package/option.md +579 -0
  19. package/package.json +33 -29
  20. package/pervasives.gr +32 -20
  21. package/queue.gr +102 -30
  22. package/queue.md +191 -0
  23. package/range.gr +26 -26
  24. package/range.md +1 -1
  25. package/regex.gr +3055 -0
  26. package/regex.md +449 -0
  27. package/result.gr +216 -70
  28. package/result.md +446 -0
  29. package/runtime/dataStructures.gr +28 -29
  30. package/runtime/debug.gr +0 -1
  31. package/runtime/equal.gr +37 -16
  32. package/runtime/exception.gr +28 -15
  33. package/runtime/gc.gr +33 -20
  34. package/runtime/malloc.gr +19 -11
  35. package/runtime/numberUtils.gr +208 -105
  36. package/runtime/numbers.gr +217 -118
  37. package/runtime/string.gr +150 -59
  38. package/runtime/stringUtils.gr +176 -0
  39. package/runtime/unsafe/conv.gr +51 -8
  40. package/runtime/unsafe/memory.gr +14 -3
  41. package/runtime/unsafe/printWasm.gr +4 -4
  42. package/runtime/unsafe/tags.gr +2 -2
  43. package/runtime/unsafe/wasmf32.gr +9 -2
  44. package/runtime/unsafe/wasmf64.gr +9 -2
  45. package/runtime/unsafe/wasmi32.gr +65 -47
  46. package/runtime/unsafe/wasmi64.gr +78 -50
  47. package/runtime/wasi.gr +199 -45
  48. package/set.gr +281 -119
  49. package/set.md +502 -0
  50. package/stack.gr +26 -26
  51. package/stack.md +143 -0
  52. package/string.gr +697 -329
  53. package/string.md +815 -0
  54. package/sys/file.gr +356 -177
  55. package/sys/process.gr +10 -6
  56. package/sys/random.gr +3 -6
  57. package/sys/time.gr +3 -3
package/stack.md ADDED
@@ -0,0 +1,143 @@
1
+ ---
2
+ title: Stack
3
+ ---
4
+
5
+ An immutable stack implementation. A stack is a LIFO (last-in-first-out) data structure where new values are added, retrieved, and removed from the end.
6
+
7
+ ```grain
8
+ import Stack from "stack"
9
+ ```
10
+
11
+ ## Types
12
+
13
+ Type declarations included in the Stack module.
14
+
15
+ ### Stack.**Stack**
16
+
17
+ ```grain
18
+ record Stack<a> {
19
+ data: List<a>,
20
+ }
21
+ ```
22
+
23
+ Stacks are immutable data structures that store their data in a List.
24
+
25
+ ## Values
26
+
27
+ Functions and constants included in the Stack module.
28
+
29
+ ### Stack.**make**
30
+
31
+ ```grain
32
+ make : () -> Stack<a>
33
+ ```
34
+
35
+ Creates a new stack.
36
+
37
+ Returns:
38
+
39
+ |type|description|
40
+ |----|-----------|
41
+ |`Stack<a>`|An empty stack|
42
+
43
+ ### Stack.**isEmpty**
44
+
45
+ ```grain
46
+ isEmpty : Stack<a> -> Bool
47
+ ```
48
+
49
+ Checks if the given stack contains no items.
50
+
51
+ Parameters:
52
+
53
+ |param|type|description|
54
+ |-----|----|-----------|
55
+ |`stack`|`Stack<a>`|The stack to check|
56
+
57
+ Returns:
58
+
59
+ |type|description|
60
+ |----|-----------|
61
+ |`Bool`|`true` if the stack has no items, and `false` otherwise|
62
+
63
+ ### Stack.**peek**
64
+
65
+ ```grain
66
+ peek : Stack<a> -> Option<a>
67
+ ```
68
+
69
+ Returns `Some(item)` where `item` is the value at the top of the stack, and `None` otherwise.
70
+
71
+ Parameters:
72
+
73
+ |param|type|description|
74
+ |-----|----|-----------|
75
+ |`stack`|`Stack<a>`|The stack to inspect|
76
+
77
+ Returns:
78
+
79
+ |type|description|
80
+ |----|-----------|
81
+ |`Option<a>`|The value at the top of the stack, if it exists|
82
+
83
+ ### Stack.**push**
84
+
85
+ ```grain
86
+ push : (a, Stack<a>) -> Stack<a>
87
+ ```
88
+
89
+ Adds a new item to the top of the stack.
90
+
91
+ Parameters:
92
+
93
+ |param|type|description|
94
+ |-----|----|-----------|
95
+ |`value`|`a`|The item to be added|
96
+ |`stack`|`Stack<a>`|The stack being updated|
97
+
98
+ Returns:
99
+
100
+ |type|description|
101
+ |----|-----------|
102
+ |`Stack<a>`|A new stack with the item added to the end|
103
+
104
+ ### Stack.**pop**
105
+
106
+ ```grain
107
+ pop : Stack<a> -> Stack<a>
108
+ ```
109
+
110
+ Removes the item at the top of the stack.
111
+
112
+ Parameters:
113
+
114
+ |param|type|description|
115
+ |-----|----|-----------|
116
+ |`stack`|`Stack<a>`|The stack being updated|
117
+
118
+ Returns:
119
+
120
+ |type|description|
121
+ |----|-----------|
122
+ |`Stack<a>`|A new stack with the last item removed|
123
+
124
+ ### Stack.**size**
125
+
126
+ ```grain
127
+ size : Stack<a> -> Number
128
+ ```
129
+
130
+ Computes the size of the input stack.
131
+
132
+ Parameters:
133
+
134
+ |param|type|description|
135
+ |-----|----|-----------|
136
+ |`stack`|`Stack<a>`|The stack to inspect|
137
+
138
+ Returns:
139
+
140
+ |type|description|
141
+ |----|-----------|
142
+ |`Number`|The count of the items in the stack|
143
+