@fraczak/k 6.3.1 → 6.3.3
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/DOCS/REPL.md +15 -10
- package/a.klib +1 -1
- package/a.kvm +142676 -0
- package/a.wasm +0 -0
- package/benchmark-results.html +532 -0
- package/benchmark-results.json +480 -0
- package/codecs/json.mjs +16 -2
- package/kvm.mjs +78 -11
- package/package.json +4 -1
- package/repl-codecs.mjs +28 -14
- package/repl.mjs +74 -11
- package/scripts/benchmark.mjs +393 -0
- package/scripts/git-hooks/pre-commit +10 -0
- package/scripts/render-benchmark.mjs +343 -0
- package/scripts/run-tests.mjs +1 -0
- package/tests/integration.sh +7 -0
- package/tests/test-arithmetics.mjs +95 -0
- package/tests/test-ieee-arithmetic.mjs +2 -2
- package/tests/test-repl.mjs +32 -1
package/DOCS/REPL.md
CHANGED
|
@@ -47,7 +47,7 @@ complete.
|
|
|
47
47
|
| `:rels` | List relation aliases |
|
|
48
48
|
| `:codec load file` | Load an importable REPL codec module |
|
|
49
49
|
| `:codec list` | List loaded REPL codecs |
|
|
50
|
-
| `:input type [codec]` | Read the next line as codec input for a
|
|
50
|
+
| `:input type [codec]` | Read the next line as codec input for a type |
|
|
51
51
|
| `:load [--no-alias] file` | Load `.k` source or `.klib` into the current state |
|
|
52
52
|
| `:klib file` | Export the active relation closure as a `.klib` library |
|
|
53
53
|
| `:ko file expr` | Export a `.ko` executable with `expr` as main |
|
|
@@ -139,7 +139,7 @@ Tab completion covers:
|
|
|
139
139
|
Type aliases also complete in `$name` position inside raw k input.
|
|
140
140
|
|
|
141
141
|
For codec commands, completion covers `:codec load`, `:codec list`, file paths
|
|
142
|
-
after `:codec load`,
|
|
142
|
+
after `:codec load`, type names after `:input`, and loaded codec names
|
|
143
143
|
after the input type.
|
|
144
144
|
|
|
145
145
|
## Loading
|
|
@@ -158,8 +158,10 @@ unless `--no-alias` is used.
|
|
|
158
158
|
|
|
159
159
|
## Codecs
|
|
160
160
|
|
|
161
|
-
REPL codecs are keyed by canonical
|
|
162
|
-
|
|
161
|
+
REPL codecs are usually keyed by canonical code hashes. Patterns are not used
|
|
162
|
+
for codec dispatch. A codec may also export `universal = true` to make it
|
|
163
|
+
available for any type selected by `:input`; the parsed value is still validated
|
|
164
|
+
against the requested type before it enters the session.
|
|
163
165
|
|
|
164
166
|
### `:codec load file`
|
|
165
167
|
|
|
@@ -172,15 +174,18 @@ export function parse(text) { /* text -> Value */ }
|
|
|
172
174
|
export function print(value) { /* Value -> text */ }
|
|
173
175
|
```
|
|
174
176
|
|
|
175
|
-
A codec may export `patterns` instead of `codes`; each pattern must be a
|
|
176
|
-
|
|
177
|
-
REPL.
|
|
177
|
+
A codec may export `patterns` instead of `codes`; each pattern must be a closed
|
|
178
|
+
property-list pattern that can be canonicalized to a code hash, and that hash is
|
|
179
|
+
recalculated by the REPL. A universal codec exports `universal = true` instead
|
|
180
|
+
of `codes` or `patterns`.
|
|
178
181
|
|
|
179
182
|
### `:input type [codec]`
|
|
180
183
|
|
|
181
|
-
Resolves `type` to a canonical
|
|
182
|
-
|
|
183
|
-
|
|
184
|
+
Resolves `type` to a canonical code hash, selects the registered codec, and
|
|
185
|
+
consumes the next line verbatim as codec input. `type` may be a type alias, a
|
|
186
|
+
canonical code hash, or an inline type expression such as
|
|
187
|
+
`<{} true, {} false>`. The parsed value is validated against that type before
|
|
188
|
+
becoming the current value.
|
|
184
189
|
|
|
185
190
|
## Export
|
|
186
191
|
|