@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/float32.md CHANGED
@@ -10,12 +10,28 @@ No other changes yet.
10
10
  </details>
11
11
 
12
12
  ```grain
13
- import Float32 from "float32"
13
+ from "float32" include Float32
14
14
  ```
15
15
 
16
- ## Constants
16
+ ```grain
17
+ 4.0f
18
+ ```
19
+
20
+ ```grain
21
+ -4.0f
22
+ ```
23
+
24
+ ```grain
25
+ Infinityf
26
+ ```
27
+
28
+ ```grain
29
+ NaNf
30
+ ```
31
+
32
+ ## Values
17
33
 
18
- Float32 constant values.
34
+ Functions and constants included in the Float32 module.
19
35
 
20
36
  ### Float32.**infinity**
21
37
 
@@ -29,6 +45,7 @@ infinity : Float32
29
45
  ```
30
46
 
31
47
  Infinity represented as a Float32 value.
48
+ This is an alternative to the `Infinityf` literal.
32
49
 
33
50
  ### Float32.**nan**
34
51
 
@@ -42,6 +59,7 @@ nan : Float32
42
59
  ```
43
60
 
44
61
  NaN (Not a Number) represented as a Float32 value.
62
+ This is an alternative to the `NaNf` literal.
45
63
 
46
64
  ### Float32.**pi**
47
65
 
@@ -82,10 +100,6 @@ e : Float32
82
100
 
83
101
  Euler's number represented as a Float32 value.
84
102
 
85
- ## Conversions
86
-
87
- Functions for converting between Numbers and the Float32 type.
88
-
89
103
  ### Float32.**fromNumber**
90
104
 
91
105
  <details disabled>
@@ -94,7 +108,7 @@ No other changes yet.
94
108
  </details>
95
109
 
96
110
  ```grain
97
- fromNumber : Number -> Float32
111
+ fromNumber : (number: Number) => Float32
98
112
  ```
99
113
 
100
114
  Converts a Number to a Float32.
@@ -119,7 +133,7 @@ No other changes yet.
119
133
  </details>
120
134
 
121
135
  ```grain
122
- toNumber : Float32 -> Number
136
+ toNumber : (float: Float32) => Number
123
137
  ```
124
138
 
125
139
  Converts a Float32 to a Number.
@@ -136,19 +150,22 @@ Returns:
136
150
  |----|-----------|
137
151
  |`Number`|The Float32 represented as a Number|
138
152
 
139
- ## Operations
140
-
141
- Mathematical operations for Float32 values.
142
-
143
- ### Float32.**add**
144
-
145
- <details disabled>
146
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
147
- No other changes yet.
153
+ ### Float32.**(+)**
154
+
155
+ <details>
156
+ <summary>Added in <code>0.6.0</code></summary>
157
+ <table>
158
+ <thead>
159
+ <tr><th>version</th><th>changes</th></tr>
160
+ </thead>
161
+ <tbody>
162
+ <tr><td><code>0.2.0</code></td><td>Originally named `add`</td></tr>
163
+ </tbody>
164
+ </table>
148
165
  </details>
149
166
 
150
167
  ```grain
151
- add : (Float32, Float32) -> Float32
168
+ (+) : (x: Float32, y: Float32) => Float32
152
169
  ```
153
170
 
154
171
  Computes the sum of its operands.
@@ -166,15 +183,29 @@ Returns:
166
183
  |----|-----------|
167
184
  |`Float32`|The sum of the two operands|
168
185
 
169
- ### Float32.**sub**
186
+ Examples:
170
187
 
171
- <details disabled>
172
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
173
- No other changes yet.
188
+ ```grain
189
+ use Float32.{ (+) }
190
+ assert 1.0f + 1.0f == 2.0f
191
+ ```
192
+
193
+ ### Float32.**(-)**
194
+
195
+ <details>
196
+ <summary>Added in <code>0.6.0</code></summary>
197
+ <table>
198
+ <thead>
199
+ <tr><th>version</th><th>changes</th></tr>
200
+ </thead>
201
+ <tbody>
202
+ <tr><td><code>0.2.0</code></td><td>Originally named `sub`</td></tr>
203
+ </tbody>
204
+ </table>
174
205
  </details>
175
206
 
176
207
  ```grain
177
- sub : (Float32, Float32) -> Float32
208
+ (-) : (x: Float32, y: Float32) => Float32
178
209
  ```
179
210
 
180
211
  Computes the difference of its operands.
@@ -192,15 +223,29 @@ Returns:
192
223
  |----|-----------|
193
224
  |`Float32`|The difference of the two operands|
194
225
 
195
- ### Float32.**mul**
226
+ Examples:
196
227
 
197
- <details disabled>
198
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
199
- No other changes yet.
228
+ ```grain
229
+ use Float32.{ (-) }
230
+ assert 1.0f - 1.0f == 0.0f
231
+ ```
232
+
233
+ ### Float32.**(*)**
234
+
235
+ <details>
236
+ <summary>Added in <code>0.6.0</code></summary>
237
+ <table>
238
+ <thead>
239
+ <tr><th>version</th><th>changes</th></tr>
240
+ </thead>
241
+ <tbody>
242
+ <tr><td><code>0.2.0</code></td><td>Originally named `mul`</td></tr>
243
+ </tbody>
244
+ </table>
200
245
  </details>
201
246
 
202
247
  ```grain
203
- mul : (Float32, Float32) -> Float32
248
+ (*) : (x: Float32, y: Float32) => Float32
204
249
  ```
205
250
 
206
251
  Computes the product of its operands.
@@ -218,15 +263,29 @@ Returns:
218
263
  |----|-----------|
219
264
  |`Float32`|The product of the two operands|
220
265
 
221
- ### Float32.**div**
266
+ Examples:
222
267
 
223
- <details disabled>
224
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
225
- No other changes yet.
268
+ ```grain
269
+ use Float32.{ (*) }
270
+ assert 2.0f * 2.0f == 4.0f
271
+ ```
272
+
273
+ ### Float32.**(/)**
274
+
275
+ <details>
276
+ <summary>Added in <code>0.6.0</code></summary>
277
+ <table>
278
+ <thead>
279
+ <tr><th>version</th><th>changes</th></tr>
280
+ </thead>
281
+ <tbody>
282
+ <tr><td><code>0.2.0</code></td><td>Originally named `div`</td></tr>
283
+ </tbody>
284
+ </table>
226
285
  </details>
227
286
 
228
287
  ```grain
229
- div : (Float32, Float32) -> Float32
288
+ (/) : (x: Float32, y: Float32) => Float32
230
289
  ```
231
290
 
232
291
  Computes the quotient of its operands.
@@ -244,19 +303,29 @@ Returns:
244
303
  |----|-----------|
245
304
  |`Float32`|The quotient of the two operands|
246
305
 
247
- ## Comparisons
248
-
249
- Functions for comparing Float32 values.
306
+ Examples:
250
307
 
251
- ### Float32.**lt**
308
+ ```grain
309
+ use Float32.{ (/) }
310
+ assert 10.0f / 4.0f == 2.5f
311
+ ```
252
312
 
253
- <details disabled>
254
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
255
- No other changes yet.
313
+ ### Float32.**(<)**
314
+
315
+ <details>
316
+ <summary>Added in <code>0.6.0</code></summary>
317
+ <table>
318
+ <thead>
319
+ <tr><th>version</th><th>changes</th></tr>
320
+ </thead>
321
+ <tbody>
322
+ <tr><td><code>0.2.0</code></td><td>Originally named `lt`</td></tr>
323
+ </tbody>
324
+ </table>
256
325
  </details>
257
326
 
258
327
  ```grain
259
- lt : (Float32, Float32) -> Bool
328
+ (<) : (x: Float32, y: Float32) => Bool
260
329
  ```
261
330
 
262
331
  Checks if the first value is less than the second value.
@@ -274,15 +343,29 @@ Returns:
274
343
  |----|-----------|
275
344
  |`Bool`|`true` if the first value is less than the second value or `false` otherwise|
276
345
 
277
- ### Float32.**gt**
346
+ Examples:
278
347
 
279
- <details disabled>
280
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
281
- No other changes yet.
348
+ ```grain
349
+ use Float32.{ (<) }
350
+ assert 1.0f < 2.0f
351
+ ```
352
+
353
+ ### Float32.**(>)**
354
+
355
+ <details>
356
+ <summary>Added in <code>0.6.0</code></summary>
357
+ <table>
358
+ <thead>
359
+ <tr><th>version</th><th>changes</th></tr>
360
+ </thead>
361
+ <tbody>
362
+ <tr><td><code>0.2.0</code></td><td>Originally named `gt`</td></tr>
363
+ </tbody>
364
+ </table>
282
365
  </details>
283
366
 
284
367
  ```grain
285
- gt : (Float32, Float32) -> Bool
368
+ (>) : (x: Float32, y: Float32) => Bool
286
369
  ```
287
370
 
288
371
  Checks if the first value is greater than the second value.
@@ -300,15 +383,29 @@ Returns:
300
383
  |----|-----------|
301
384
  |`Bool`|`true` if the first value is greater than the second value or `false` otherwise|
302
385
 
303
- ### Float32.**lte**
386
+ Examples:
304
387
 
305
- <details disabled>
306
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
307
- No other changes yet.
388
+ ```grain
389
+ use Float32.{ (>) }
390
+ assert 2.0f > 1.0f
391
+ ```
392
+
393
+ ### Float32.**(<=)**
394
+
395
+ <details>
396
+ <summary>Added in <code>0.6.0</code></summary>
397
+ <table>
398
+ <thead>
399
+ <tr><th>version</th><th>changes</th></tr>
400
+ </thead>
401
+ <tbody>
402
+ <tr><td><code>0.2.0</code></td><td>Originally named `lte`</td></tr>
403
+ </tbody>
404
+ </table>
308
405
  </details>
309
406
 
310
407
  ```grain
311
- lte : (Float32, Float32) -> Bool
408
+ (<=) : (x: Float32, y: Float32) => Bool
312
409
  ```
313
410
 
314
411
  Checks if the first value is less than or equal to the second value.
@@ -326,15 +423,34 @@ Returns:
326
423
  |----|-----------|
327
424
  |`Bool`|`true` if the first value is less than or equal to the second value or `false` otherwise|
328
425
 
329
- ### Float32.**gte**
426
+ Examples:
330
427
 
331
- <details disabled>
332
- <summary tabindex="-1">Added in <code>0.2.0</code></summary>
333
- No other changes yet.
428
+ ```grain
429
+ use Float32.{ (<=) }
430
+ assert -1.0f <= 1.0f
431
+ ```
432
+
433
+ ```grain
434
+ use Float32.{ (<=) }
435
+ assert -2.0f <= -2.0f
436
+ ```
437
+
438
+ ### Float32.**(>=)**
439
+
440
+ <details>
441
+ <summary>Added in <code>0.6.0</code></summary>
442
+ <table>
443
+ <thead>
444
+ <tr><th>version</th><th>changes</th></tr>
445
+ </thead>
446
+ <tbody>
447
+ <tr><td><code>0.2.0</code></td><td>Originally named `gte`</td></tr>
448
+ </tbody>
449
+ </table>
334
450
  </details>
335
451
 
336
452
  ```grain
337
- gte : (Float32, Float32) -> Bool
453
+ (>=) : (x: Float32, y: Float32) => Bool
338
454
  ```
339
455
 
340
456
  Checks if the first value is greater than or equal to the second value.
@@ -352,3 +468,15 @@ Returns:
352
468
  |----|-----------|
353
469
  |`Bool`|`true` if the first value is greater than or equal to the second value or `false` otherwise|
354
470
 
471
+ Examples:
472
+
473
+ ```grain
474
+ use Float32.{ (>=) }
475
+ assert 4.0f >= 1.0f
476
+ ```
477
+
478
+ ```grain
479
+ use Float32.{ (>=) }
480
+ assert 3.0f >= 3.0f
481
+ ```
482
+
package/float64.gr CHANGED
@@ -1,100 +1,69 @@
1
1
  /**
2
- * @module Float64: Utilities for working with the Float64 type.
3
- * @example import Float64 from "float64"
4
- *
2
+ * Utilities for working with the Float64 type.
3
+ *
4
+ * @example from "float64" include Float64
5
+ *
6
+ * @example 5.0d
7
+ * @example -5.0d
8
+ * @example Infinityd
9
+ * @example NaNd
10
+ *
5
11
  * @since v0.2.0
6
12
  */
7
- import WasmI32 from "runtime/unsafe/wasmi32"
8
- import WasmF64 from "runtime/unsafe/wasmf64"
9
- import { newFloat64 } from "runtime/dataStructures"
13
+ module Float64
14
+
15
+ from "runtime/unsafe/wasmi32" include WasmI32
16
+ from "runtime/unsafe/wasmf64" include WasmF64
17
+ use WasmF64.{ (-), (+), (*), (/), (<), (<=), (>), (>=) }
18
+ from "runtime/dataStructures" include DataStructures
19
+ use DataStructures.{ newFloat64 }
10
20
 
11
- import {
21
+ from "runtime/numbers" include Numbers
22
+ use Numbers.{
12
23
  coerceNumberToFloat64 as fromNumber,
13
24
  coerceFloat64ToNumber as toNumber,
14
- } from "runtime/numbers"
15
-
16
- /**
17
- * @section Constants: Float64 constant values.
18
- */
25
+ }
19
26
 
20
27
  /**
21
28
  * Infinity represented as a Float64 value.
22
- *
29
+ * This is an alternative to the `Infinityd` literal.
30
+ *
23
31
  * @since v0.4.0
24
32
  */
25
33
  @unsafe
26
- export let infinity = {
27
- let ptr = newFloat64(
28
- WasmF64.reinterpretI64(
29
- 0b0111111111110000000000000000000000000000000000000000000000000000N
30
- )
31
- )
32
- WasmI32.toGrain(ptr): Float64
33
- }
34
+ provide let infinity = Infinityd
34
35
 
35
36
  /**
36
37
  * NaN (Not a Number) represented as a Float64 value.
37
- *
38
+ * This is an alternative to the `NaNd` literal.
39
+ *
38
40
  * @since v0.4.0
39
41
  */
40
42
  @unsafe
41
- export let nan = {
42
- let ptr = newFloat64(
43
- WasmF64.reinterpretI64(
44
- 0b0111111111110000000000000000000000000000000000000000000000000001N
45
- )
46
- )
47
- WasmI32.toGrain(ptr): Float64
48
- }
43
+ provide let nan = NaNd
49
44
 
50
45
  /**
51
46
  * Pi represented as a Float64 value.
52
- *
47
+ *
53
48
  * @since v0.5.2
54
49
  */
55
- export let pi = 3.141592653589793d
50
+ provide let pi = 3.141592653589793d
56
51
 
57
52
  /**
58
53
  * Tau represented as a Float64 value.
59
- *
54
+ *
60
55
  * @since v0.5.2
61
56
  */
62
- export let tau = 6.283185307179586d
57
+ provide let tau = 6.283185307179586d
63
58
 
64
59
  /**
65
60
  * Euler's number represented as a Float64 value.
66
- *
67
- * @since v0.5.2
68
- */
69
- export let e = 2.718281828459045d
70
-
71
- /**
72
- * @section Conversions: Functions for converting between Numbers and the Float64 type.
73
- */
74
-
75
- /**
76
- * Converts a Number to a Float64.
77
61
  *
78
- * @param number: The value to convert
79
- * @returns The Number represented as a Float64
80
- *
81
- * @since v0.2.0
62
+ * @since v0.5.2
82
63
  */
83
- export fromNumber
64
+ provide let e = 2.718281828459045d
84
65
 
85
- /**
86
- * Converts a Float64 to a Number.
87
- *
88
- * @param float: The value to convert
89
- * @returns The Float64 represented as a Number
90
- *
91
- * @since v0.2.0
92
- */
93
- export toNumber
94
-
95
- /**
96
- * @section Operations: Mathematical operations for Float64 values.
97
- */
66
+ provide { fromNumber, toNumber }
98
67
 
99
68
  /**
100
69
  * Computes the sum of its operands.
@@ -102,14 +71,19 @@ export toNumber
102
71
  * @param x: The first operand
103
72
  * @param y: The second operand
104
73
  * @returns The sum of the two operands
105
- *
106
- * @since v0.2.0
74
+ *
75
+ * @example
76
+ * use Float64.{ (+) }
77
+ * assert 1.0d + 1.0d == 2.0d
78
+ *
79
+ * @since v0.6.0
80
+ * @history v0.2.0: Originally named `add`
107
81
  */
108
82
  @unsafe
109
- export let add = (x: Float64, y: Float64) => {
83
+ provide let (+) = (x: Float64, y: Float64) => {
110
84
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
111
85
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
112
- let ptr = newFloat64(WasmF64.add(xv, yv))
86
+ let ptr = newFloat64(xv + yv)
113
87
  WasmI32.toGrain(ptr): Float64
114
88
  }
115
89
 
@@ -119,14 +93,19 @@ export let add = (x: Float64, y: Float64) => {
119
93
  * @param x: The first operand
120
94
  * @param y: The second operand
121
95
  * @returns The difference of the two operands
122
- *
123
- * @since v0.2.0
96
+ *
97
+ * @example
98
+ * use Float64.{ (-) }
99
+ * assert 5.0d - 4.0d == 1.0d
100
+ *
101
+ * @since v0.6.0
102
+ * @history v0.2.0: Originally named `sub`
124
103
  */
125
104
  @unsafe
126
- export let sub = (x: Float64, y: Float64) => {
105
+ provide let (-) = (x: Float64, y: Float64) => {
127
106
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
128
107
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
129
- let ptr = newFloat64(WasmF64.sub(xv, yv))
108
+ let ptr = newFloat64(xv - yv)
130
109
  WasmI32.toGrain(ptr): Float64
131
110
  }
132
111
 
@@ -136,14 +115,19 @@ export let sub = (x: Float64, y: Float64) => {
136
115
  * @param x: The first operand
137
116
  * @param y: The second operand
138
117
  * @returns The product of the two operands
139
- *
140
- * @since v0.2.0
118
+ *
119
+ * @example
120
+ * use Float64.{ (*) }
121
+ * assert -5.0d * 4.0d == -20.0d
122
+ *
123
+ * @since v0.6.0
124
+ * @history v0.2.0: Originally named `mul`
141
125
  */
142
126
  @unsafe
143
- export let mul = (x: Float64, y: Float64) => {
127
+ provide let (*) = (x: Float64, y: Float64) => {
144
128
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
145
129
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
146
- let ptr = newFloat64(WasmF64.mul(xv, yv))
130
+ let ptr = newFloat64(xv * yv)
147
131
  WasmI32.toGrain(ptr): Float64
148
132
  }
149
133
 
@@ -153,35 +137,41 @@ export let mul = (x: Float64, y: Float64) => {
153
137
  * @param x: The first operand
154
138
  * @param y: The second operand
155
139
  * @returns The quotient of the two operands
156
- *
157
- * @since v0.2.0
140
+ *
141
+ * @example
142
+ * use Float64.{ (/) }
143
+ * assert 25.0d / 4.0d == 6.25d
144
+ *
145
+ * @since v0.6.0
146
+ * @history v0.2.0: Originally named `div`
158
147
  */
159
148
  @unsafe
160
- export let div = (x: Float64, y: Float64) => {
149
+ provide let (/) = (x: Float64, y: Float64) => {
161
150
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
162
151
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
163
- let ptr = newFloat64(WasmF64.div(xv, yv))
152
+ let ptr = newFloat64(xv / yv)
164
153
  WasmI32.toGrain(ptr): Float64
165
154
  }
166
155
 
167
- /**
168
- * @section Comparisons: Functions for comparing Float64 values.
169
- */
170
-
171
156
  /**
172
157
  * Checks if the first value is less than the second value.
173
158
  *
174
159
  * @param x: The first value
175
160
  * @param y: The second value
176
161
  * @returns `true` if the first value is less than the second value or `false` otherwise
177
- *
178
- * @since v0.2.0
162
+ *
163
+ * @example
164
+ * use Float64.{ (<) }
165
+ * assert -5.0d < 5.0d
166
+ *
167
+ * @since v0.6.0
168
+ * @history v0.2.0: Originally named `lt`
179
169
  */
180
170
  @unsafe
181
- export let lt = (x: Float64, y: Float64) => {
171
+ provide let (<) = (x: Float64, y: Float64) => {
182
172
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
183
173
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
184
- WasmF64.lt(xv, yv)
174
+ xv < yv
185
175
  }
186
176
 
187
177
  /**
@@ -190,14 +180,19 @@ export let lt = (x: Float64, y: Float64) => {
190
180
  * @param x: The first value
191
181
  * @param y: The second value
192
182
  * @returns `true` if the first value is greater than the second value or `false` otherwise
193
- *
194
- * @since v0.2.0
183
+ *
184
+ * @example
185
+ * use Float64.{ (>) }
186
+ * assert 6.0d > 5.0d
187
+ *
188
+ * @since v0.6.0
189
+ * @history v0.2.0: Originally named `gt`
195
190
  */
196
191
  @unsafe
197
- export let gt = (x: Float64, y: Float64) => {
192
+ provide let (>) = (x: Float64, y: Float64) => {
198
193
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
199
194
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
200
- WasmF64.gt(xv, yv)
195
+ xv > yv
201
196
  }
202
197
 
203
198
  /**
@@ -206,14 +201,23 @@ export let gt = (x: Float64, y: Float64) => {
206
201
  * @param x: The first value
207
202
  * @param y: The second value
208
203
  * @returns `true` if the first value is less than or equal to the second value or `false` otherwise
209
- *
210
- * @since v0.2.0
204
+ *
205
+ * @example
206
+ * use Float64.{ (<=) }
207
+ * assert 1.0d <= 2.0d
208
+ *
209
+ * @example
210
+ * use Float64.{ (<=) }
211
+ * assert 2.0d <= 2.0d
212
+ *
213
+ * @since v0.6.0
214
+ * @history v0.2.0: Originally named `lte`
211
215
  */
212
216
  @unsafe
213
- export let lte = (x: Float64, y: Float64) => {
217
+ provide let (<=) = (x: Float64, y: Float64) => {
214
218
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
215
219
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
216
- WasmF64.le(xv, yv)
220
+ xv <= yv
217
221
  }
218
222
 
219
223
  /**
@@ -222,12 +226,21 @@ export let lte = (x: Float64, y: Float64) => {
222
226
  * @param x: The first value
223
227
  * @param y: The second value
224
228
  * @returns `true` if the first value is greater than or equal to the second value or `false` otherwise
225
- *
226
- * @since v0.2.0
229
+ *
230
+ * @example
231
+ * use Float64.{ (>=) }
232
+ * assert 5.0d >= 2.0d
233
+ *
234
+ * @example
235
+ * use Float64.{ (>=) }
236
+ * assert -1.0d >= -1.0d
237
+ *
238
+ * @since v0.6.0
239
+ * @history v0.2.0: Originally named `gte`
227
240
  */
228
241
  @unsafe
229
- export let gte = (x: Float64, y: Float64) => {
242
+ provide let (>=) = (x: Float64, y: Float64) => {
230
243
  let xv = WasmF64.load(WasmI32.fromGrain(x), 8n)
231
244
  let yv = WasmF64.load(WasmI32.fromGrain(y), 8n)
232
- WasmF64.ge(xv, yv)
245
+ xv >= yv
233
246
  }