@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.
- package/CHANGELOG.md +67 -0
- package/LICENSE +1 -1
- package/README.md +2 -2
- package/array.gr +55 -7
- package/array.md +606 -560
- package/bigint.md +228 -228
- package/buffer.gr +85 -53
- package/buffer.md +442 -319
- package/bytes.gr +112 -35
- package/bytes.md +299 -219
- package/char.gr +201 -99
- package/char.md +447 -120
- package/exception.gr +11 -11
- package/exception.md +29 -4
- package/float32.gr +327 -3
- package/float32.md +698 -111
- package/float64.gr +320 -3
- package/float64.md +698 -111
- package/fs.gr +1082 -0
- package/fs.md +630 -0
- package/hash.gr +142 -88
- package/hash.md +105 -17
- package/int16.md +178 -178
- package/int32.gr +26 -5
- package/int32.md +266 -231
- package/int64.gr +27 -2
- package/int64.md +266 -231
- package/int8.md +178 -178
- package/json.gr +366 -51
- package/json.md +431 -15
- package/list.gr +328 -31
- package/list.md +759 -336
- package/map.gr +20 -12
- package/map.md +266 -260
- package/marshal.gr +41 -40
- package/marshal.md +14 -14
- package/number.gr +278 -35
- package/number.md +688 -269
- package/option.md +162 -162
- package/package.json +5 -3
- package/path.gr +48 -0
- package/path.md +180 -89
- package/pervasives.gr +2 -2
- package/pervasives.md +275 -275
- package/priorityqueue.gr +7 -7
- package/priorityqueue.md +131 -131
- package/queue.gr +183 -29
- package/queue.md +404 -148
- package/random.md +43 -43
- package/range.gr +4 -4
- package/range.md +42 -42
- package/rational.md +123 -123
- package/regex.gr +52 -51
- package/regex.md +102 -102
- package/result.md +118 -118
- package/runtime/atof/common.md +39 -39
- package/runtime/atof/decimal.gr +6 -6
- package/runtime/atof/decimal.md +14 -14
- package/runtime/atof/lemire.gr +5 -5
- package/runtime/atof/lemire.md +1 -1
- package/runtime/atof/parse.gr +16 -16
- package/runtime/atof/parse.md +2 -2
- package/runtime/atof/slow.md +1 -1
- package/runtime/atof/table.md +2 -2
- package/runtime/atoi/parse.gr +3 -3
- package/runtime/atoi/parse.md +1 -1
- package/runtime/bigint.gr +15 -47
- package/runtime/bigint.md +54 -60
- package/runtime/compare.gr +2 -2
- package/runtime/compare.md +8 -8
- package/runtime/dataStructures.md +211 -211
- package/runtime/debugPrint.gr +4 -1
- package/runtime/debugPrint.md +9 -9
- package/runtime/equal.gr +99 -77
- package/runtime/equal.md +8 -8
- package/runtime/exception.gr +62 -82
- package/runtime/exception.md +62 -11
- package/runtime/gc.gr +39 -45
- package/runtime/gc.md +4 -4
- package/runtime/malloc.gr +7 -7
- package/runtime/malloc.md +13 -13
- package/runtime/math/kernel/cos.gr +70 -0
- package/runtime/math/kernel/cos.md +14 -0
- package/runtime/math/kernel/sin.gr +65 -0
- package/runtime/math/kernel/sin.md +14 -0
- package/runtime/math/kernel/tan.gr +136 -0
- package/runtime/math/kernel/tan.md +14 -0
- package/runtime/math/rempio2.gr +244 -0
- package/runtime/math/rempio2.md +14 -0
- package/runtime/math/trig.gr +130 -0
- package/runtime/math/trig.md +28 -0
- package/runtime/math/umuldi.gr +26 -0
- package/runtime/math/umuldi.md +14 -0
- package/runtime/numberUtils.gr +29 -29
- package/runtime/numberUtils.md +12 -12
- package/runtime/numbers.gr +373 -381
- package/runtime/numbers.md +348 -342
- package/runtime/string.gr +37 -105
- package/runtime/string.md +20 -26
- package/runtime/unsafe/constants.md +24 -24
- package/runtime/unsafe/conv.md +19 -19
- package/runtime/unsafe/memory.gr +24 -20
- package/runtime/unsafe/memory.md +27 -7
- package/runtime/unsafe/offsets.gr +36 -0
- package/runtime/unsafe/offsets.md +88 -0
- package/runtime/unsafe/panic.gr +28 -0
- package/runtime/unsafe/panic.md +14 -0
- package/runtime/unsafe/tags.md +32 -32
- package/runtime/unsafe/wasmf32.md +28 -28
- package/runtime/unsafe/wasmf64.md +28 -28
- package/runtime/unsafe/wasmi32.md +47 -47
- package/runtime/unsafe/wasmi64.md +50 -50
- package/runtime/utf8.gr +189 -0
- package/runtime/utf8.md +117 -0
- package/runtime/wasi.gr +4 -2
- package/runtime/wasi.md +147 -147
- package/set.gr +18 -11
- package/set.md +253 -247
- package/stack.gr +171 -2
- package/stack.md +371 -89
- package/string.gr +352 -557
- package/string.md +298 -255
- package/uint16.md +170 -170
- package/uint32.gr +25 -4
- package/uint32.md +249 -214
- package/uint64.gr +25 -5
- package/uint64.md +249 -214
- package/uint8.md +170 -170
- package/uri.gr +57 -53
- package/uri.md +88 -89
- package/wasi/file.gr +67 -59
- package/wasi/file.md +308 -308
- package/wasi/process.md +26 -26
- package/wasi/random.md +12 -12
- package/wasi/time.md +16 -16
- package/runtime/utils/printing.gr +0 -60
- package/runtime/utils/printing.md +0 -26
package/char.md
CHANGED
|
@@ -27,6 +27,27 @@ from "char" include Char
|
|
|
27
27
|
'🌾'
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
## Types
|
|
31
|
+
|
|
32
|
+
Type declarations included in the Char module.
|
|
33
|
+
|
|
34
|
+
### Char.**Encoding**
|
|
35
|
+
|
|
36
|
+
<details disabled>
|
|
37
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
38
|
+
No other changes yet.
|
|
39
|
+
</details>
|
|
40
|
+
|
|
41
|
+
```grain
|
|
42
|
+
enum Encoding {
|
|
43
|
+
UTF8,
|
|
44
|
+
UTF16,
|
|
45
|
+
UTF32,
|
|
46
|
+
}
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Byte encodings
|
|
50
|
+
|
|
30
51
|
## Values
|
|
31
52
|
|
|
32
53
|
Functions and constants included in the Char module.
|
|
@@ -39,7 +60,7 @@ No other changes yet.
|
|
|
39
60
|
</details>
|
|
40
61
|
|
|
41
62
|
```grain
|
|
42
|
-
min
|
|
63
|
+
min: Number
|
|
43
64
|
```
|
|
44
65
|
|
|
45
66
|
The minimum valid Unicode scalar value.
|
|
@@ -52,7 +73,7 @@ No other changes yet.
|
|
|
52
73
|
</details>
|
|
53
74
|
|
|
54
75
|
```grain
|
|
55
|
-
max
|
|
76
|
+
max: Number
|
|
56
77
|
```
|
|
57
78
|
|
|
58
79
|
The maximum valid Unicode scalar value.
|
|
@@ -65,22 +86,22 @@ No other changes yet.
|
|
|
65
86
|
</details>
|
|
66
87
|
|
|
67
88
|
```grain
|
|
68
|
-
isValid
|
|
89
|
+
isValid: (charCode: Number) => Bool
|
|
69
90
|
```
|
|
70
91
|
|
|
71
92
|
Determines whether the given character code is a valid Unicode scalar value.
|
|
72
93
|
|
|
73
94
|
Parameters:
|
|
74
95
|
|
|
75
|
-
|param|type|description|
|
|
76
|
-
|
|
77
|
-
|
|
96
|
+
| param | type | description |
|
|
97
|
+
| ---------- | -------- | ------------------- |
|
|
98
|
+
| `charCode` | `Number` | The number to check |
|
|
78
99
|
|
|
79
100
|
Returns:
|
|
80
101
|
|
|
81
|
-
|type|description|
|
|
82
|
-
|
|
83
|
-
|
|
102
|
+
| type | description |
|
|
103
|
+
| ------ | -------------------------------------------------------------------------------- |
|
|
104
|
+
| `Bool` | `true` if the number refers to a valid Unicode scalar value or `false` otherwise |
|
|
84
105
|
|
|
85
106
|
Examples:
|
|
86
107
|
|
|
@@ -100,22 +121,22 @@ No other changes yet.
|
|
|
100
121
|
</details>
|
|
101
122
|
|
|
102
123
|
```grain
|
|
103
|
-
code
|
|
124
|
+
code: (char: Char) => Number
|
|
104
125
|
```
|
|
105
126
|
|
|
106
127
|
Determines the Unicode scalar value for a character.
|
|
107
128
|
|
|
108
129
|
Parameters:
|
|
109
130
|
|
|
110
|
-
|param|type|description|
|
|
111
|
-
|
|
112
|
-
|
|
131
|
+
| param | type | description |
|
|
132
|
+
| ------ | ------ | ------------- |
|
|
133
|
+
| `char` | `Char` | The character |
|
|
113
134
|
|
|
114
135
|
Returns:
|
|
115
136
|
|
|
116
|
-
|type|description|
|
|
117
|
-
|
|
118
|
-
|
|
137
|
+
| type | description |
|
|
138
|
+
| -------- | ------------------------------------------------ |
|
|
139
|
+
| `Number` | The Unicode scalar value for the given character |
|
|
119
140
|
|
|
120
141
|
Examples:
|
|
121
142
|
|
|
@@ -135,22 +156,22 @@ No other changes yet.
|
|
|
135
156
|
</details>
|
|
136
157
|
|
|
137
158
|
```grain
|
|
138
|
-
fromCode
|
|
159
|
+
fromCode: (usv: Number) => Char
|
|
139
160
|
```
|
|
140
161
|
|
|
141
162
|
Creates a character from the given Unicode scalar value.
|
|
142
163
|
|
|
143
164
|
Parameters:
|
|
144
165
|
|
|
145
|
-
|param|type|description|
|
|
146
|
-
|
|
147
|
-
|
|
166
|
+
| param | type | description |
|
|
167
|
+
| ----- | -------- | ------------------------ |
|
|
168
|
+
| `usv` | `Number` | The Unicode scalar value |
|
|
148
169
|
|
|
149
170
|
Returns:
|
|
150
171
|
|
|
151
|
-
|type|description|
|
|
152
|
-
|
|
153
|
-
|
|
172
|
+
| type | description |
|
|
173
|
+
| ------ | ------------------------------------------------ |
|
|
174
|
+
| `Char` | The character for the given Unicode scalar value |
|
|
154
175
|
|
|
155
176
|
Throws:
|
|
156
177
|
|
|
@@ -176,22 +197,22 @@ No other changes yet.
|
|
|
176
197
|
</details>
|
|
177
198
|
|
|
178
199
|
```grain
|
|
179
|
-
succ
|
|
200
|
+
succ: (char: Char) => Char
|
|
180
201
|
```
|
|
181
202
|
|
|
182
203
|
Returns the next valid character by Unicode scalar value.
|
|
183
204
|
|
|
184
205
|
Parameters:
|
|
185
206
|
|
|
186
|
-
|param|type|description|
|
|
187
|
-
|
|
188
|
-
|
|
207
|
+
| param | type | description |
|
|
208
|
+
| ------ | ------ | ------------- |
|
|
209
|
+
| `char` | `Char` | The character |
|
|
189
210
|
|
|
190
211
|
Returns:
|
|
191
212
|
|
|
192
|
-
|type|description|
|
|
193
|
-
|
|
194
|
-
|
|
213
|
+
| type | description |
|
|
214
|
+
| ------ | ------------------------------------------------ |
|
|
215
|
+
| `Char` | The next valid character by Unicode scalar value |
|
|
195
216
|
|
|
196
217
|
Throws:
|
|
197
218
|
|
|
@@ -217,22 +238,22 @@ No other changes yet.
|
|
|
217
238
|
</details>
|
|
218
239
|
|
|
219
240
|
```grain
|
|
220
|
-
pred
|
|
241
|
+
pred: (char: Char) => Char
|
|
221
242
|
```
|
|
222
243
|
|
|
223
244
|
Returns the previous valid character by Unicode scalar value.
|
|
224
245
|
|
|
225
246
|
Parameters:
|
|
226
247
|
|
|
227
|
-
|param|type|description|
|
|
228
|
-
|
|
229
|
-
|
|
248
|
+
| param | type | description |
|
|
249
|
+
| ------ | ------ | ------------- |
|
|
250
|
+
| `char` | `Char` | The character |
|
|
230
251
|
|
|
231
252
|
Returns:
|
|
232
253
|
|
|
233
|
-
|type|description|
|
|
234
|
-
|
|
235
|
-
|
|
254
|
+
| type | description |
|
|
255
|
+
| ------ | ---------------------------------------------------- |
|
|
256
|
+
| `Char` | The previous valid character by Unicode scalar value |
|
|
236
257
|
|
|
237
258
|
Throws:
|
|
238
259
|
|
|
@@ -258,22 +279,22 @@ No other changes yet.
|
|
|
258
279
|
</details>
|
|
259
280
|
|
|
260
281
|
```grain
|
|
261
|
-
toString
|
|
282
|
+
toString: (char: Char) => String
|
|
262
283
|
```
|
|
263
284
|
|
|
264
285
|
Converts the given character to a string.
|
|
265
286
|
|
|
266
287
|
Parameters:
|
|
267
288
|
|
|
268
|
-
|param|type|description|
|
|
269
|
-
|
|
270
|
-
|
|
289
|
+
| param | type | description |
|
|
290
|
+
| ------ | ------ | ------------------------ |
|
|
291
|
+
| `char` | `Char` | The character to convert |
|
|
271
292
|
|
|
272
293
|
Returns:
|
|
273
294
|
|
|
274
|
-
|type|description|
|
|
275
|
-
|
|
276
|
-
|
|
295
|
+
| type | description |
|
|
296
|
+
| -------- | --------------------------------------- |
|
|
297
|
+
| `String` | A string containing the given character |
|
|
277
298
|
|
|
278
299
|
Examples:
|
|
279
300
|
|
|
@@ -285,6 +306,46 @@ Char.toString('a') == "a"
|
|
|
285
306
|
Char.toString('🌾') == "🌾"
|
|
286
307
|
```
|
|
287
308
|
|
|
309
|
+
### Char.**encodedLength**
|
|
310
|
+
|
|
311
|
+
<details disabled>
|
|
312
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
313
|
+
No other changes yet.
|
|
314
|
+
</details>
|
|
315
|
+
|
|
316
|
+
```grain
|
|
317
|
+
encodedLength: (encoding: Encoding, char: Char) => Number
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Returns the byte count of a character if encoded in the given encoding.
|
|
321
|
+
|
|
322
|
+
Parameters:
|
|
323
|
+
|
|
324
|
+
| param | type | description |
|
|
325
|
+
| ---------- | ---------- | --------------------- |
|
|
326
|
+
| `encoding` | `Encoding` | The encoding to check |
|
|
327
|
+
| `char` | `Char` | The character |
|
|
328
|
+
|
|
329
|
+
Returns:
|
|
330
|
+
|
|
331
|
+
| type | description |
|
|
332
|
+
| -------- | ----------------------------------------------------- |
|
|
333
|
+
| `Number` | The byte count of the character in the given encoding |
|
|
334
|
+
|
|
335
|
+
Examples:
|
|
336
|
+
|
|
337
|
+
```grain
|
|
338
|
+
Char.encodedLength(Char.UTF8, 'a') == 1
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
```grain
|
|
342
|
+
Char.encodedLength(Char.UTF8, '🌾') == 4
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
```grain
|
|
346
|
+
Char.encodedLength(Char.UTF16, '©') == 1
|
|
347
|
+
```
|
|
348
|
+
|
|
288
349
|
### Char.**(<)**
|
|
289
350
|
|
|
290
351
|
<details disabled>
|
|
@@ -293,23 +354,23 @@ No other changes yet.
|
|
|
293
354
|
</details>
|
|
294
355
|
|
|
295
356
|
```grain
|
|
296
|
-
(<)
|
|
357
|
+
(<): (x: Char, y: Char) => Bool
|
|
297
358
|
```
|
|
298
359
|
|
|
299
360
|
Checks if the first character is less than the second character by Unicode scalar value.
|
|
300
361
|
|
|
301
362
|
Parameters:
|
|
302
363
|
|
|
303
|
-
|param|type|description|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
364
|
+
| param | type | description |
|
|
365
|
+
| ----- | ------ | -------------------- |
|
|
366
|
+
| `x` | `Char` | The first character |
|
|
367
|
+
| `y` | `Char` | The second character |
|
|
307
368
|
|
|
308
369
|
Returns:
|
|
309
370
|
|
|
310
|
-
|type|description|
|
|
311
|
-
|
|
312
|
-
|
|
371
|
+
| type | description |
|
|
372
|
+
| ------ | ------------------------------------------------------------------------------------ |
|
|
373
|
+
| `Bool` | `true` if the first character is less than the second character or `false` otherwise |
|
|
313
374
|
|
|
314
375
|
Examples:
|
|
315
376
|
|
|
@@ -331,23 +392,23 @@ No other changes yet.
|
|
|
331
392
|
</details>
|
|
332
393
|
|
|
333
394
|
```grain
|
|
334
|
-
(<=)
|
|
395
|
+
(<=): (x: Char, y: Char) => Bool
|
|
335
396
|
```
|
|
336
397
|
|
|
337
398
|
Checks if the first character is less than or equal to the second character by Unicode scalar value.
|
|
338
399
|
|
|
339
400
|
Parameters:
|
|
340
401
|
|
|
341
|
-
|param|type|description|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
402
|
+
| param | type | description |
|
|
403
|
+
| ----- | ------ | -------------------- |
|
|
404
|
+
| `x` | `Char` | The first character |
|
|
405
|
+
| `y` | `Char` | The second character |
|
|
345
406
|
|
|
346
407
|
Returns:
|
|
347
408
|
|
|
348
|
-
|type|description|
|
|
349
|
-
|
|
350
|
-
|
|
409
|
+
| type | description |
|
|
410
|
+
| ------ | ------------------------------------------------------------------------------------------------ |
|
|
411
|
+
| `Bool` | `true` if the first character is less than or equal to the second character or `false` otherwise |
|
|
351
412
|
|
|
352
413
|
Examples:
|
|
353
414
|
|
|
@@ -374,23 +435,23 @@ No other changes yet.
|
|
|
374
435
|
</details>
|
|
375
436
|
|
|
376
437
|
```grain
|
|
377
|
-
(>)
|
|
438
|
+
(>): (x: Char, y: Char) => Bool
|
|
378
439
|
```
|
|
379
440
|
|
|
380
441
|
Checks if the first character is greater than the second character by Unicode scalar value.
|
|
381
442
|
|
|
382
443
|
Parameters:
|
|
383
444
|
|
|
384
|
-
|param|type|description|
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
445
|
+
| param | type | description |
|
|
446
|
+
| ----- | ------ | -------------------- |
|
|
447
|
+
| `x` | `Char` | The first character |
|
|
448
|
+
| `y` | `Char` | The second character |
|
|
388
449
|
|
|
389
450
|
Returns:
|
|
390
451
|
|
|
391
|
-
|type|description|
|
|
392
|
-
|
|
393
|
-
|
|
452
|
+
| type | description |
|
|
453
|
+
| ------ | --------------------------------------------------------------------------------------- |
|
|
454
|
+
| `Bool` | `true` if the first character is greater than the second character or `false` otherwise |
|
|
394
455
|
|
|
395
456
|
Examples:
|
|
396
457
|
|
|
@@ -412,23 +473,23 @@ No other changes yet.
|
|
|
412
473
|
</details>
|
|
413
474
|
|
|
414
475
|
```grain
|
|
415
|
-
(>=)
|
|
476
|
+
(>=): (x: Char, y: Char) => Bool
|
|
416
477
|
```
|
|
417
478
|
|
|
418
479
|
Checks if the first character is greater than or equal to the second character by Unicode scalar value.
|
|
419
480
|
|
|
420
481
|
Parameters:
|
|
421
482
|
|
|
422
|
-
|param|type|description|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
483
|
+
| param | type | description |
|
|
484
|
+
| ----- | ------ | -------------------- |
|
|
485
|
+
| `x` | `Char` | The first character |
|
|
486
|
+
| `y` | `Char` | The second character |
|
|
426
487
|
|
|
427
488
|
Returns:
|
|
428
489
|
|
|
429
|
-
|type|description|
|
|
430
|
-
|
|
431
|
-
|
|
490
|
+
| type | description |
|
|
491
|
+
| ------ | --------------------------------------------------------------------------------------------------- |
|
|
492
|
+
| `Bool` | `true` if the first character is greater than or equal to the second character or `false` otherwise |
|
|
432
493
|
|
|
433
494
|
Examples:
|
|
434
495
|
|
|
@@ -447,135 +508,401 @@ use Char.{ (>=) }
|
|
|
447
508
|
assert 'a' >= 'a'
|
|
448
509
|
```
|
|
449
510
|
|
|
450
|
-
|
|
511
|
+
## Char.Ascii
|
|
512
|
+
|
|
513
|
+
Utilities for working with ASCII characters.
|
|
451
514
|
|
|
452
515
|
<details disabled>
|
|
453
|
-
<summary tabindex="-1">Added in <code>0.
|
|
516
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
517
|
+
No other changes yet.
|
|
518
|
+
</details>
|
|
519
|
+
|
|
520
|
+
```grain
|
|
521
|
+
Char.Ascii.isAscii('1')
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
### Values
|
|
525
|
+
|
|
526
|
+
Functions and constants included in the Char.Ascii module.
|
|
527
|
+
|
|
528
|
+
#### Char.Ascii.**min**
|
|
529
|
+
|
|
530
|
+
<details disabled>
|
|
531
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
454
532
|
No other changes yet.
|
|
455
533
|
</details>
|
|
456
534
|
|
|
457
535
|
```grain
|
|
458
|
-
|
|
536
|
+
min: Number
|
|
537
|
+
```
|
|
538
|
+
|
|
539
|
+
The minimum valid ASCII character code.
|
|
540
|
+
|
|
541
|
+
#### Char.Ascii.**max**
|
|
542
|
+
|
|
543
|
+
<details disabled>
|
|
544
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
545
|
+
No other changes yet.
|
|
546
|
+
</details>
|
|
547
|
+
|
|
548
|
+
```grain
|
|
549
|
+
max: Number
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
The maximum valid ASCII character code.
|
|
553
|
+
|
|
554
|
+
#### Char.Ascii.**isValid**
|
|
555
|
+
|
|
556
|
+
<details disabled>
|
|
557
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
558
|
+
No other changes yet.
|
|
559
|
+
</details>
|
|
560
|
+
|
|
561
|
+
```grain
|
|
562
|
+
isValid: (char: Char) => Bool
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
Checks if the character is a valid ASCII character.
|
|
566
|
+
|
|
567
|
+
Parameters:
|
|
568
|
+
|
|
569
|
+
| param | type | description |
|
|
570
|
+
| ------ | ------ | ---------------------- |
|
|
571
|
+
| `char` | `Char` | The character to check |
|
|
572
|
+
|
|
573
|
+
Returns:
|
|
574
|
+
|
|
575
|
+
| type | description |
|
|
576
|
+
| ------ | ------------------------------------------------------------------ |
|
|
577
|
+
| `Bool` | `true` if the character is an ASCII character or `false` otherwise |
|
|
578
|
+
|
|
579
|
+
Examples:
|
|
580
|
+
|
|
581
|
+
```grain
|
|
582
|
+
assert Char.Ascii.isValid('1')
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
```grain
|
|
586
|
+
assert Char.Ascii.isValid('a')
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
```grain
|
|
590
|
+
assert !Char.Ascii.isValid('🌾')
|
|
591
|
+
```
|
|
592
|
+
|
|
593
|
+
#### Char.Ascii.**isDigit**
|
|
594
|
+
|
|
595
|
+
<details>
|
|
596
|
+
<summary>Added in <code>0.7.0</code></summary>
|
|
597
|
+
<table>
|
|
598
|
+
<thead>
|
|
599
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
600
|
+
</thead>
|
|
601
|
+
<tbody>
|
|
602
|
+
<tr><td><code>0.6.0</code></td><td>Originally `Char.isAsciiDigit`</td></tr>
|
|
603
|
+
</tbody>
|
|
604
|
+
</table>
|
|
605
|
+
</details>
|
|
606
|
+
|
|
607
|
+
```grain
|
|
608
|
+
isDigit: (char: Char) => Bool
|
|
459
609
|
```
|
|
460
610
|
|
|
461
611
|
Checks if the character is an ASCII digit.
|
|
462
612
|
|
|
463
613
|
Parameters:
|
|
464
614
|
|
|
465
|
-
|param|type|description|
|
|
466
|
-
|
|
467
|
-
|
|
615
|
+
| param | type | description |
|
|
616
|
+
| ------ | ------ | ---------------------- |
|
|
617
|
+
| `char` | `Char` | The character to check |
|
|
618
|
+
|
|
619
|
+
Returns:
|
|
620
|
+
|
|
621
|
+
| type | description |
|
|
622
|
+
| ------ | -------------------------------------------------------------- |
|
|
623
|
+
| `Bool` | `true` if the character is an ASCII digit or `false` otherwise |
|
|
624
|
+
|
|
625
|
+
Examples:
|
|
626
|
+
|
|
627
|
+
```grain
|
|
628
|
+
assert Char.Ascii.isDigit('1')
|
|
629
|
+
```
|
|
630
|
+
|
|
631
|
+
```grain
|
|
632
|
+
assert !Char.Ascii.isDigit('a')
|
|
633
|
+
```
|
|
634
|
+
|
|
635
|
+
#### Char.Ascii.**isAlpha**
|
|
636
|
+
|
|
637
|
+
<details>
|
|
638
|
+
<summary>Added in <code>0.7.0</code></summary>
|
|
639
|
+
<table>
|
|
640
|
+
<thead>
|
|
641
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
642
|
+
</thead>
|
|
643
|
+
<tbody>
|
|
644
|
+
<tr><td><code>0.6.0</code></td><td>Originally `Char.isAsciiAlpha`</td></tr>
|
|
645
|
+
</tbody>
|
|
646
|
+
</table>
|
|
647
|
+
</details>
|
|
648
|
+
|
|
649
|
+
```grain
|
|
650
|
+
isAlpha: (char: Char) => Bool
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
Checks if the character is an ASCII alphabetical character.
|
|
654
|
+
|
|
655
|
+
Parameters:
|
|
656
|
+
|
|
657
|
+
| param | type | description |
|
|
658
|
+
| ------ | ------ | ---------------------- |
|
|
659
|
+
| `char` | `Char` | The character to check |
|
|
468
660
|
|
|
469
661
|
Returns:
|
|
470
662
|
|
|
471
|
-
|type|description|
|
|
472
|
-
|
|
473
|
-
|
|
663
|
+
| type | description |
|
|
664
|
+
| ------ | --------------------------------------------------------------------- |
|
|
665
|
+
| `Bool` | `true` if the character is an ASCII alphabetical or `false` otherwise |
|
|
474
666
|
|
|
475
667
|
Examples:
|
|
476
668
|
|
|
477
669
|
```grain
|
|
478
|
-
assert Char.
|
|
670
|
+
assert Char.Ascii.isAlpha('a')
|
|
479
671
|
```
|
|
480
672
|
|
|
481
673
|
```grain
|
|
482
|
-
assert !Char.
|
|
674
|
+
assert !Char.Ascii.isAlpha('1')
|
|
483
675
|
```
|
|
484
676
|
|
|
485
|
-
|
|
677
|
+
#### Char.Ascii.**isControl**
|
|
486
678
|
|
|
487
679
|
<details disabled>
|
|
488
|
-
<summary tabindex="-1">Added in <code>0.
|
|
680
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
489
681
|
No other changes yet.
|
|
490
682
|
</details>
|
|
491
683
|
|
|
492
684
|
```grain
|
|
493
|
-
|
|
685
|
+
isControl: (char: Char) => Bool
|
|
494
686
|
```
|
|
495
687
|
|
|
496
|
-
Checks if the character is an ASCII
|
|
688
|
+
Checks if the character is an ASCII control character.
|
|
497
689
|
|
|
498
690
|
Parameters:
|
|
499
691
|
|
|
500
|
-
|param|type|description|
|
|
501
|
-
|
|
502
|
-
|
|
692
|
+
| param | type | description |
|
|
693
|
+
| ------ | ------ | ---------------------- |
|
|
694
|
+
| `char` | `Char` | The character to check |
|
|
503
695
|
|
|
504
696
|
Returns:
|
|
505
697
|
|
|
506
|
-
|type|description|
|
|
507
|
-
|
|
508
|
-
|
|
698
|
+
| type | description |
|
|
699
|
+
| ------ | -------------------------------------------------------------------------- |
|
|
700
|
+
| `Bool` | `true` if the character is an ASCII control character or `false` otherwise |
|
|
509
701
|
|
|
510
702
|
Examples:
|
|
511
703
|
|
|
512
704
|
```grain
|
|
513
|
-
assert Char.
|
|
705
|
+
assert Char.Ascii.isControl('\t')
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
```grain
|
|
709
|
+
assert Char.Ascii.isControl('\n')
|
|
710
|
+
```
|
|
711
|
+
|
|
712
|
+
```grain
|
|
713
|
+
assert !Char.Ascii.isControl('1')
|
|
514
714
|
```
|
|
515
715
|
|
|
516
716
|
```grain
|
|
517
|
-
assert !Char.
|
|
717
|
+
assert !Char.Ascii.isControl('a')
|
|
518
718
|
```
|
|
519
719
|
|
|
520
|
-
|
|
720
|
+
#### Char.Ascii.**isWhitespace**
|
|
521
721
|
|
|
522
722
|
<details disabled>
|
|
523
|
-
<summary tabindex="-1">Added in <code>0.
|
|
723
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
524
724
|
No other changes yet.
|
|
525
725
|
</details>
|
|
526
726
|
|
|
527
727
|
```grain
|
|
528
|
-
|
|
728
|
+
isWhitespace: (char: Char) => Bool
|
|
529
729
|
```
|
|
530
730
|
|
|
531
|
-
|
|
731
|
+
Checks if the character is an ASCII whitespace character.
|
|
532
732
|
|
|
533
733
|
Parameters:
|
|
534
734
|
|
|
535
|
-
|param|type|description|
|
|
536
|
-
|
|
537
|
-
|
|
735
|
+
| param | type | description |
|
|
736
|
+
| ------ | ------ | ---------------------- |
|
|
737
|
+
| `char` | `Char` | The character to check |
|
|
538
738
|
|
|
539
739
|
Returns:
|
|
540
740
|
|
|
541
|
-
|type|description|
|
|
542
|
-
|
|
543
|
-
|
|
741
|
+
| type | description |
|
|
742
|
+
| ------ | ----------------------------------------------------------------------------- |
|
|
743
|
+
| `Bool` | `true` if the character is an ASCII whitespace character or `false` otherwise |
|
|
544
744
|
|
|
545
745
|
Examples:
|
|
546
746
|
|
|
547
747
|
```grain
|
|
548
|
-
assert Char.
|
|
748
|
+
assert Char.isWhitespace('\t')
|
|
549
749
|
```
|
|
550
750
|
|
|
551
|
-
|
|
751
|
+
```grain
|
|
752
|
+
assert Char.isWhitespace('\n')
|
|
753
|
+
```
|
|
754
|
+
|
|
755
|
+
```grain
|
|
756
|
+
assert !Char.isWhitespace('1')
|
|
757
|
+
```
|
|
758
|
+
|
|
759
|
+
```grain
|
|
760
|
+
assert !Char.isWhitespace('a')
|
|
761
|
+
```
|
|
762
|
+
|
|
763
|
+
#### Char.Ascii.**isPunctuation**
|
|
552
764
|
|
|
553
765
|
<details disabled>
|
|
554
|
-
<summary tabindex="-1">Added in <code>0.
|
|
766
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
767
|
+
No other changes yet.
|
|
768
|
+
</details>
|
|
769
|
+
|
|
770
|
+
```grain
|
|
771
|
+
isPunctuation: (char: Char) => Bool
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
Checks if the character is an ASCII punctuation character.
|
|
775
|
+
|
|
776
|
+
Parameters:
|
|
777
|
+
|
|
778
|
+
| param | type | description |
|
|
779
|
+
| ------ | ------ | ---------------------- |
|
|
780
|
+
| `char` | `Char` | The character to check |
|
|
781
|
+
|
|
782
|
+
Returns:
|
|
783
|
+
|
|
784
|
+
| type | description |
|
|
785
|
+
| ------ | ------------------------------------------------------------------------------ |
|
|
786
|
+
| `Bool` | `true` if the character is an ASCII punctuation character or `false` otherwise |
|
|
787
|
+
|
|
788
|
+
Examples:
|
|
789
|
+
|
|
790
|
+
```grain
|
|
791
|
+
assert Char.Ascii.isPunctuation('!')
|
|
792
|
+
```
|
|
793
|
+
|
|
794
|
+
```grain
|
|
795
|
+
assert !Char.Ascii.isPunctuation('1')
|
|
796
|
+
```
|
|
797
|
+
|
|
798
|
+
#### Char.Ascii.**isGraphic**
|
|
799
|
+
|
|
800
|
+
<details disabled>
|
|
801
|
+
<summary tabindex="-1">Added in <code>0.7.0</code></summary>
|
|
555
802
|
No other changes yet.
|
|
556
803
|
</details>
|
|
557
804
|
|
|
558
805
|
```grain
|
|
559
|
-
|
|
806
|
+
isGraphic: (char: Char) => Bool
|
|
807
|
+
```
|
|
808
|
+
|
|
809
|
+
Checks if the character is an ASCII graphic character.
|
|
810
|
+
|
|
811
|
+
Parameters:
|
|
812
|
+
|
|
813
|
+
| param | type | description |
|
|
814
|
+
| ------ | ------ | ---------------------- |
|
|
815
|
+
| `char` | `Char` | The character to check |
|
|
816
|
+
|
|
817
|
+
Returns:
|
|
818
|
+
|
|
819
|
+
| type | description |
|
|
820
|
+
| ------ | -------------------------------------------------------------------------- |
|
|
821
|
+
| `Bool` | `true` if the character is an ASCII graphic character or `false` otherwise |
|
|
822
|
+
|
|
823
|
+
Examples:
|
|
824
|
+
|
|
825
|
+
```grain
|
|
826
|
+
assert Char.Ascii.isGraphic('!')
|
|
827
|
+
```
|
|
828
|
+
|
|
829
|
+
```grain
|
|
830
|
+
assert !Char.Ascii.isGraphic('\t')
|
|
831
|
+
```
|
|
832
|
+
|
|
833
|
+
#### Char.Ascii.**toLowercase**
|
|
834
|
+
|
|
835
|
+
<details>
|
|
836
|
+
<summary>Added in <code>0.7.0</code></summary>
|
|
837
|
+
<table>
|
|
838
|
+
<thead>
|
|
839
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
840
|
+
</thead>
|
|
841
|
+
<tbody>
|
|
842
|
+
<tr><td><code>0.6.0</code></td><td>Originally `Char.toAsciiLowercase`</td></tr>
|
|
843
|
+
</tbody>
|
|
844
|
+
</table>
|
|
845
|
+
</details>
|
|
846
|
+
|
|
847
|
+
```grain
|
|
848
|
+
toLowercase: (char: Char) => Char
|
|
849
|
+
```
|
|
850
|
+
|
|
851
|
+
Converts the character to ASCII lowercase if it is an ASCII uppercase character.
|
|
852
|
+
|
|
853
|
+
Parameters:
|
|
854
|
+
|
|
855
|
+
| param | type | description |
|
|
856
|
+
| ------ | ------ | ------------------------ |
|
|
857
|
+
| `char` | `Char` | The character to convert |
|
|
858
|
+
|
|
859
|
+
Returns:
|
|
860
|
+
|
|
861
|
+
| type | description |
|
|
862
|
+
| ------ | ------------------------ |
|
|
863
|
+
| `Char` | The lowercased character |
|
|
864
|
+
|
|
865
|
+
Examples:
|
|
866
|
+
|
|
867
|
+
```grain
|
|
868
|
+
assert Char.Ascii.toLowercase('B') == 'b'
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
#### Char.Ascii.**toUppercase**
|
|
872
|
+
|
|
873
|
+
<details>
|
|
874
|
+
<summary>Added in <code>0.7.0</code></summary>
|
|
875
|
+
<table>
|
|
876
|
+
<thead>
|
|
877
|
+
<tr><th>version</th><th>changes</th></tr>
|
|
878
|
+
</thead>
|
|
879
|
+
<tbody>
|
|
880
|
+
<tr><td><code>0.6.0</code></td><td>Originally `Char.toAsciiUppercase`</td></tr>
|
|
881
|
+
</tbody>
|
|
882
|
+
</table>
|
|
883
|
+
</details>
|
|
884
|
+
|
|
885
|
+
```grain
|
|
886
|
+
toUppercase: (char: Char) => Char
|
|
560
887
|
```
|
|
561
888
|
|
|
562
889
|
Converts the character to ASCII uppercase if it is an ASCII lowercase character.
|
|
563
890
|
|
|
564
891
|
Parameters:
|
|
565
892
|
|
|
566
|
-
|param|type|description|
|
|
567
|
-
|
|
568
|
-
|
|
893
|
+
| param | type | description |
|
|
894
|
+
| ------ | ------ | ------------------------ |
|
|
895
|
+
| `char` | `Char` | The character to convert |
|
|
569
896
|
|
|
570
897
|
Returns:
|
|
571
898
|
|
|
572
|
-
|type|description|
|
|
573
|
-
|
|
574
|
-
|
|
899
|
+
| type | description |
|
|
900
|
+
| ------ | ------------------------ |
|
|
901
|
+
| `Char` | The uppercased character |
|
|
575
902
|
|
|
576
903
|
Examples:
|
|
577
904
|
|
|
578
905
|
```grain
|
|
579
|
-
assert Char.
|
|
906
|
+
assert Char.Ascii.toUppercase('b') == 'B'
|
|
580
907
|
```
|
|
581
908
|
|