@fraczak/k 8.6.1 → 8.7.0

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 (71) hide show
  1. package/CHANGELOG.md +22 -0
  2. package/DOCS/CODECS.md +20 -14
  3. package/DOCS/FILE_FORMATS.md +79 -12
  4. package/DOCS/GETTING_STARTED.md +17 -8
  5. package/DOCS/PATTERNS.md +17 -0
  6. package/DOCS/REPL.md +13 -7
  7. package/Examples/arithmetics.k +81 -468
  8. package/Examples/ieee-arithmetics.k +37 -33
  9. package/Examples/poly.k +107 -104
  10. package/README.md +19 -11
  11. package/backend-api.mjs +3 -1
  12. package/backends/llvm/README.md +1 -1
  13. package/backends/llvm/bin/k-llvm-build.mjs +5 -5
  14. package/backends/llvm/bin/k-llvm-compile.mjs +4 -4
  15. package/backends/llvm/bin/k-llvm.mjs +6 -6
  16. package/backends/llvm/src/cli.mjs +17 -12
  17. package/backends/llvm/tests/integration.sh +4 -1
  18. package/backends/wasm/README.md +3 -3
  19. package/backends/wasm/bin/k-wasm-compile.mjs +4 -4
  20. package/backends/wasm/bin/k-wasm.mjs +4 -4
  21. package/backends/wasm/src/cli.mjs +12 -10
  22. package/backends/wasm/src/wasm.mjs +6 -2
  23. package/backends/wasm/tests/integration.sh +8 -3
  24. package/browser/shims/fs.mjs +19 -3
  25. package/canonical-pattern.mjs +217 -57
  26. package/core.k +2 -1
  27. package/harness/suites/poly.mjs +14 -30
  28. package/k.mjs +17 -13
  29. package/kvm.mjs +13 -9
  30. package/lib/arithmetics.k +287 -0
  31. package/lib/bit.k +68 -0
  32. package/lib/bits.k +221 -0
  33. package/lib/btrie.k +187 -0
  34. package/lib/djson.k +326 -0
  35. package/lib/ieee.k +709 -0
  36. package/lib/list.k +49 -0
  37. package/lib/string.k +588 -0
  38. package/named-patterns.mjs +2 -2
  39. package/object.mjs +51 -9
  40. package/objects/README.md +10 -3
  41. package/objects/compile.mjs +10 -8
  42. package/package.json +1 -1
  43. package/repl.mjs +28 -6
  44. package/scripts/benchmark-idempotency.mjs +22 -15
  45. package/scripts/benchmark.mjs +29 -10
  46. package/scripts/build-repl-html.mjs +41 -13
  47. package/scripts/perf-ieee.mjs +9 -1
  48. package/scripts/perf-int.mjs +10 -17
  49. package/scripts/perf-multiplication.mjs +9 -15
  50. package/scripts/perf-poly.mjs +16 -32
  51. package/scripts/run-tests.mjs +2 -2
  52. package/scripts/test-package.mjs +8 -2
  53. package/tests/helpers/cli.mjs +11 -3
  54. package/tests/integration.sh +9 -4
  55. package/tests/test-arithmetics.mjs +4 -2
  56. package/tests/test-djson-methods.mjs +16 -12
  57. package/tests/test-ieee-arithmetic.mjs +11 -3
  58. package/tests/test-ieee-text.mjs +15 -4
  59. package/tests/test-k-object.mjs +11 -3
  60. package/tests/test-karatsuba.mjs +1 -1
  61. package/tests/test-kvm-polymorphic.mjs +54 -34
  62. package/tests/test-lib.mjs +115 -0
  63. package/tests/test-named-patterns.mjs +12 -3
  64. package/tests/test-parse-json.mjs +33 -13
  65. package/tests/test-poly.mjs +10 -4
  66. package/tests/test-repl-html.mjs +18 -7
  67. package/tests/test-repl.mjs +50 -35
  68. package/Examples/djson.k +0 -894
  69. package/Examples/ieee.k +0 -969
  70. package/Examples/karatsuba-mult.k +0 -227
  71. package/Examples/list.k +0 -10
package/CHANGELOG.md CHANGED
@@ -5,6 +5,28 @@ All notable changes to this project will be documented here.
5
5
  The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
6
6
  This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [8.7.0] — 2026-11-07 — Standard Library Modularization and Source Header Directives
9
+
10
+ - **Standard Library Modularization into `lib/`**:
11
+ - Reorganize core library modules from `Examples/` into a dedicated `lib/` directory:
12
+ - `lib/bit.k`: Basic bit, boolean, and ternary ordering schemas (`bit[]`, `bool[]`, `order[]`).
13
+ - `lib/bits.k`: Arbitrary-width bit sequences and 8-bit bytes (`bits[]`, `byte[]`).
14
+ - `lib/arithmetics.k`: Arbitrary-precision signed integers (`int[]`) and arithmetic relations.
15
+ - `lib/list.k`: Parametric linked lists (`list[X]`).
16
+ - `lib/btrie.k`: Parametric binary tries and optional values (`opt[V]`, `btrie[V]`).
17
+ - `lib/string.k`: ASCII bytes, Unicode codepoints, and strings (`ascii[]`, `unicode[]`, `string[]`).
18
+ - `lib/ieee.k`: Binary64 IEEE 754 float types and conversion (`float64[]`).
19
+ - `lib/djson.k`: Universal dynamic JSON schema and RFC 8259 parser (`djson[]`).
20
+ - Remove all hardcoded content hashes (`@hash`) from standard library source files.
21
+ - **Source Header Directives (`# --lib ... --use ...`)**:
22
+ - Add leading `# --lib <dependency> --use <specs>` comment directives to declare library dependencies and imported symbols at the top of `.k` files without hardcoded hashes.
23
+ - Implement scoped origin resolution in the compiler so that name clashes across chained dependencies (e.g. `inc` in `lib/bits.k` vs. `lib/arithmetics.k`) resolve unambiguously to the intended origin.
24
+ - Support relation and pattern alias specs: `name`, `libname:localname`, `pattern[Params]`, and `pattern[Params]:localname[Params]`.
25
+ - **Toolchain & REPL Integration**:
26
+ - Support automatic header directive extraction across `compileLibrary`, `compileObject`, `k.mjs`, `kvm.mjs`, LLVM, and Wasm backends.
27
+ - REPL `:load` automatically parses header directives from source and binds aliases against the active session's loaded libraries.
28
+ - Update all benchmarks, test harnesses, documentation, and shell pipelines to use `lib/` and header directives.
29
+
8
30
  ## [8.6.1] — 2026-11-04 — REPL `:all-patterns` and Shared-Graph Boundary Pattern Printing
9
31
 
10
32
  - **REPL `:all-patterns` (alias `:all-pat`)**:
package/DOCS/CODECS.md CHANGED
@@ -112,20 +112,21 @@ witness derivation. General wire semantics are specified in
112
112
  | `json.mjs` / `k-json` | Document-specific schemas: objects as products, arrays as indexed products |
113
113
  | `djson.mjs` / `k-djson` | One recursive JSON representation using binary tries for objects and arrays |
114
114
 
115
- `Examples/djson.k` supplies operations such as `get`, `nth`, `set`,
115
+ `lib/djson.k` supplies operations such as `get`, `nth`, `set`,
116
116
  `del`, `push`, `keys`, and `values`. The specializing JSON codec and dynamic
117
117
  JSON codec serve different schemas; they are not interchangeable encodings.
118
118
 
119
- The library references core and IEEE types by their canonical hashes, as
120
- `poly.k` references the integer type. Its `number[]` is the IEEE `float64[]`;
121
- the sign, exponent, and fraction schemas are shared too. In the REPL, load
122
- `core.k`, `Examples/ieee.k`, then `Examples/djson.k`. When compiling, build the
123
- IEEE library with core first so it carries both sets of types.
119
+ The library references earlier `lib/` types by their canonical hashes. Its
120
+ `number[]` is the IEEE `float64[]`; the sign, exponent, and fraction schemas
121
+ are shared too. In the REPL, load `lib/bit.k`, `lib/bits.k`, `lib/list.k`,
122
+ `lib/btrie.k`, `lib/string.k`, `lib/ieee.k`, then `lib/djson.k`. When
123
+ compiling, chain the `lib/` modules in order so each `.klib` carries forward
124
+ the accumulated definitions.
124
125
 
125
- `Examples/ieee.k` contains the binary64 representation, small constructors and
126
+ `lib/ieee.k` contains the binary64 representation, constructors and
126
127
  predicates, and text conversion. Heavy add/subtract/multiply/divide definitions
127
- are in `Examples/ieee-arithmetics.k`; load that file after `core.k` and `ieee.k`
128
- when arithmetic is needed. JSON parsing uses the lightweight library alone.
128
+ are in `Examples/ieee-arithmetics.k`; load that file after `lib/ieee.k`
129
+ when arithmetic is needed. JSON parsing uses `lib/ieee.k` alone.
129
130
 
130
131
  `parseFloat64`: `string[]` → `float64[]` accepts JSON-style decimal syntax,
131
132
  an optional leading `+`, surrounding ASCII JSON whitespace, and the words
@@ -145,10 +146,15 @@ surrogate escapes, and numbers that overflow to infinity are undefined.
145
146
  For example, decode UTF-8 to a k string, then parse that string in k:
146
147
 
147
148
  ```sh
148
- node objects/compile.mjs --lib core.k Examples/ieee.k /tmp/ieee-core.klib
149
- node objects/compile.mjs --lib /tmp/ieee-core.klib Examples/djson.k /tmp/djson.klib
149
+ node objects/compile.mjs lib/bit.k /tmp/bit.klib
150
+ node objects/compile.mjs --lib /tmp/bit.klib lib/bits.k /tmp/bits.klib
151
+ node objects/compile.mjs --lib /tmp/bits.klib lib/list.k /tmp/list.klib
152
+ node objects/compile.mjs --lib /tmp/list.klib lib/btrie.k /tmp/btrie.klib
153
+ node objects/compile.mjs --lib /tmp/btrie.klib lib/string.k /tmp/string.klib
154
+ node objects/compile.mjs --lib /tmp/string.klib lib/ieee.k /tmp/ieee.klib
155
+ node objects/compile.mjs --lib /tmp/ieee.klib lib/djson.k /tmp/djson.klib
150
156
  printf '%s' '{"answer":42}' | node codecs/utf8.mjs --parse |
151
- node k.mjs --lib /tmp/djson.klib --export parseJson 'parseJson' |
157
+ node k.mjs --lib /tmp/djson.klib --use parseJson 'parseJson' |
152
158
  node codecs/djson.mjs --print
153
159
  ```
154
160
 
@@ -160,14 +166,14 @@ The compiled IEEE library also supports a complete text round-trip in k:
160
166
 
161
167
  ```sh
162
168
  printf '%s' '1.5' | node codecs/utf8.mjs --parse |
163
- node k.mjs --lib /tmp/ieee-core.klib --export parseFloat64 --export printFloat64 'parseFloat64 printFloat64' |
169
+ node k.mjs --lib /tmp/ieee.klib --use parseFloat64 --use printFloat64 'parseFloat64 printFloat64' |
164
170
  node codecs/utf8.mjs --print
165
171
  ```
166
172
 
167
173
  For arithmetic, compile the optional layer against the same IEEE library:
168
174
 
169
175
  ```sh
170
- node objects/compile.mjs --lib /tmp/ieee-core.klib Examples/ieee-arithmetics.k /tmp/ieee-arithmetics.klib
176
+ node objects/compile.mjs --lib /tmp/ieee.klib Examples/ieee-arithmetics.k /tmp/ieee-arithmetics.klib
171
177
  ```
172
178
 
173
179
  `k-parse` and `k-print` use [textual k values](TEXTUAL_VALUES.md), rather than
@@ -58,7 +58,7 @@ given. `-o` / `--output` is an alternative to the positional output path.
58
58
 
59
59
  ```sh
60
60
  node objects/compile.mjs 'greet = {} |hello;' /tmp/k-demo.klib
61
- node objects/compile.mjs --lib /tmp/k-demo.klib --export greet 'greet' /tmp/k-greet.ko
61
+ node objects/compile.mjs --lib /tmp/k-demo.klib --use greet 'greet' /tmp/k-greet.ko
62
62
  node codecs/unit.mjs --parse | node k.mjs /tmp/k-greet.ko |
63
63
  node codecs/k-print.mjs
64
64
  ```
@@ -67,23 +67,90 @@ This prints `"hello"`. `--lib` loads a dependency; it does not select library
67
67
  output. These are equivalent ways to generate a library from source:
68
68
 
69
69
  ```sh
70
- node objects/compile.mjs Examples/arithmetics.k /tmp/k-math.klib
71
- node objects/compile.mjs --format klib Examples/arithmetics.k /tmp/k-math.klib
70
+ node objects/compile.mjs lib/bit.k /tmp/bit.klib
71
+ node objects/compile.mjs --lib /tmp/bit.klib lib/bits.k /tmp/bits.klib
72
+ node objects/compile.mjs --lib /tmp/bits.klib lib/arithmetics.k /tmp/k-math.klib
72
73
  ```
73
74
 
74
- Only one `--lib` is accepted by the current CLI. The dependency's relations are
75
- available under canonical hashes; friendly aliases require explicit
76
- `--export name` or `--export libraryName:localName` mappings. Repeat
77
- `--export` for each needed alias. Source can reference hashes directly.
75
+ Only one `--lib` is accepted on the command line by current CLI tools. Chained
76
+ libraries carry forward definitions from their predecessors, so compiling a
77
+ series of libraries extends the environment cumulatively.
78
78
 
79
- For example, increment a decimal input using a library relation:
79
+ ### Source header directives (`# --lib ... --use ...`)
80
80
 
81
- ```sh
82
- printf '42\n' | node codecs/int.mjs --parse |
83
- node k.mjs --lib /tmp/k-math.klib --export inc 'inc' |
84
- node codecs/int.mjs --print
81
+ To avoid scattering hardcoded content hashes (`@hash`) throughout source code,
82
+ `.k` files declare their library dependencies and imported symbols using header
83
+ comment directives at the very top of the file:
84
+
85
+ ```k
86
+ # --lib <dependency-path> --use <spec1> <spec2> ...
85
87
  ```
86
88
 
89
+ #### Syntax
90
+
91
+ 1. **Placement**: Directives must appear in the first comment block at the very
92
+ top of the file, before any relation or pattern definitions.
93
+ 2. **Comment prefix**: Directives start with `# --lib` (or `# lib`). Because `#`
94
+ is a standard one-line comment character in k, the line is fully valid k
95
+ syntax and is ignored by basic parsers.
96
+ 3. **Target library**: `<dependency-path>` indicates the library providing the
97
+ symbols (for example, `lib/bits.k` or `lib/string.k`).
98
+ 4. **Import specs**: `--use` is followed by one or more whitespace- or
99
+ comma-separated specs:
100
+ - `name`: imports the relation or pattern `name` into local scope under the
101
+ same name (emits `name = @hash;` or `name[X] = @hash[X];`).
102
+ - `libname:localname`: imports the relation or pattern `libname` under a local
103
+ alias `localname` (emits `localname = @hash;`).
104
+ - `pattern[Params]`: imports a named pattern explicitly with its parameter
105
+ signature (e.g. `btrie[V]` or `byte[]`).
106
+ - `pattern[Params]:localname[Params]`: imports a named pattern under a local
107
+ alias (e.g. `float64[]:number[]`).
108
+
109
+ Multiple `# --lib` lines can be declared to import from different libraries or
110
+ to group imports logically:
111
+
112
+ ```k
113
+ # --lib lib/bits.k --use trim inv_loop inv cmp
114
+ # --lib lib/bits.k --use inc:inc_bits dec:dec_bits plus:plus_bits minus:minus_bits mul:mul_bits
115
+ ```
116
+
117
+ #### How the compiler interprets header directives
118
+
119
+ When source code is compiled with library dependencies (`k-compile`, `k.mjs`,
120
+ `compileLibrary`, `compileObject`, or the REPL's `:load`):
121
+
122
+ 1. **Extraction**: The compiler extracts all `# --lib` directives from the
123
+ leading comment block.
124
+ 2. **Scoped origin resolution**: Symbols are looked up against the loaded
125
+ libraries. If multiple loaded libraries contain definitions with the same
126
+ name (for example, `inc` in `lib/bits.k` for bit-tree increments versus `inc`
127
+ in `lib/arithmetics.k` for signed integer increments), the directive
128
+ `# --lib lib/bits.k --use inc:inc_bits` checks the metadata origins of the
129
+ libraries to bind the exact definition authored in `lib/bits.k`.
130
+ 3. **Preamble generation**: The compiler generates an in-memory alias preamble
131
+ mapping each symbol to its canonical hash (e.g. `inc_bits = @RFYjYZZ...;`)
132
+ and prepends it to the compilation unit.
133
+ 4. **Deduplication**: Aliases are deduplicated by local target name, avoiding
134
+ redundant definitions if a symbol is referenced across multiple directives
135
+ or CLI options.
136
+
137
+ #### Interaction with CLI `--lib` and `--use`
138
+
139
+ - When compiling a source file that already declares its imports via `# --lib`
140
+ header comments, you only need to supply `--lib <file.klib>` on the command
141
+ line. You **do not** need to repeat the `--use` flags; the compiler reads them
142
+ directly from the source header:
143
+ ```sh
144
+ node objects/compile.mjs --lib /tmp/bits.klib lib/list.k /tmp/list.klib
145
+ ```
146
+ - Command-line `--use spec` flags remain available for ad-hoc snippets or to
147
+ override/supplement aliases when invoking `k.mjs` or `k-compile`:
148
+ ```sh
149
+ printf '42\n' | node codecs/int.mjs --parse |
150
+ node k.mjs --lib /tmp/k-math.klib --use inc 'inc' |
151
+ node codecs/int.mjs --print
152
+ ```
153
+
87
154
  This prints `43`. Numeral names such as `5` in the arithmetic library are
88
155
  relations producing bit trees. `5 int` constructs a signed integer; numeral
89
156
  names are not builtin literals.
@@ -117,10 +117,12 @@ constraints. Derivation convergence does not prove that every program terminates
117
117
 
118
118
  ## Libraries and external numbers
119
119
 
120
- Load the integer library and a codec explicitly:
120
+ Load the integer library chain and a codec explicitly:
121
121
 
122
122
  ```text
123
- :load Examples/arithmetics.k
123
+ :load lib/bit.k
124
+ :load lib/bits.k
125
+ :load lib/arithmetics.k
124
126
  :codec load codecs/int.mjs
125
127
  :input int.mjs 42
126
128
  ```
@@ -128,13 +130,13 @@ Load the integer library and a codec explicitly:
128
130
  Now evaluate `inc` to obtain 43. The codec prints the decimal representation
129
131
  alongside the structural value.
130
132
 
131
- For list operations, load the arithmetic library first, then:
133
+ For list operations, load `lib/list.k` and `Examples/poly.k`:
132
134
 
133
135
  ```text
136
+ :load lib/list.k
134
137
  :load Examples/poly.k
135
138
  ```
136
139
 
137
- For a smaller self-contained list example, use `:load Examples/list.k`.
138
140
  See the [REPL guide](REPL.md) for loading, pattern inspection, and exports.
139
141
 
140
142
  ## Shell pipelines
@@ -143,14 +145,21 @@ The command-line runtime receives binary schema+payload data, so use codecs
143
145
  at text boundaries. From the repository root:
144
146
 
145
147
  ```sh
148
+ node objects/compile.mjs lib/bit.k /tmp/bit.klib
149
+ node objects/compile.mjs --lib /tmp/bit.klib lib/bits.k /tmp/bits.klib
150
+ node objects/compile.mjs --lib /tmp/bits.klib lib/arithmetics.k /tmp/arithmetics.klib
146
151
  printf '42\n' | node codecs/int.mjs --parse |
147
- node k.mjs --lib Examples/arithmetics.k --export inc 'inc' |
152
+ node k.mjs --lib /tmp/arithmetics.klib --use inc 'inc' |
148
153
  node codecs/int.mjs --print
149
154
  ```
150
155
 
151
- This prints `43`. `--lib` loads definitions; `--export inc` brings the
152
- friendly name into scope. Library relations are also available by their
153
- content hashes.
156
+ This prints `43`. When compiling chained libraries such as `lib/bits.k` or
157
+ `lib/arithmetics.k`, dependencies and imported aliases are declared directly in
158
+ the source header comments (`# --lib ... --use ...`), so explicit `--use` flags
159
+ are not needed on the compile command line. For ad-hoc expressions on the CLI,
160
+ `--use inc` brings the library relation into scope from the command line.
161
+ Library relations and patterns are also accessible by their canonical content
162
+ hashes.
154
163
 
155
164
  To compile a small executable object and run it:
156
165
 
package/DOCS/PATTERNS.md CHANGED
@@ -36,6 +36,23 @@ Relations can refer to other definitions in the same source, including recursive
36
36
  references. Labels can be identifiers or quoted strings with escapes. Line
37
37
  comments use `--`, `//`, `#`, or `%`; block comments use `/* ... */`.
38
38
 
39
+ ### Source header directives and library imports
40
+
41
+ Files can declare library dependencies and imported symbols using header comment directives at the very top of the file:
42
+
43
+ ```k
44
+ # --lib <dependency-path> --use <spec1> <spec2> ...
45
+ ```
46
+
47
+ Because `#` is a standard line comment character in k, this directive is valid k syntax and is ignored by basic parsers. The compilation toolchain (`k-compile`, `compileLibrary`, `k.mjs`, `kvm.mjs`, backends, and the REPL) inspects the first comment block and automatically binds each imported symbol to its canonical content hash:
48
+
49
+ - `name`: imports relation or pattern `name` into local scope under the same name.
50
+ - `libname:localname`: imports relation or pattern `libname` under a local alias `localname`.
51
+ - `pattern[Params]`: imports a named pattern template explicitly with parameter signature (e.g. `btrie[V]` or `byte[]`).
52
+ - `pattern[Params]:localname[Params]`: imports a named pattern template under a local alias (e.g. `float64[]:number[]`).
53
+
54
+ Directives can be repeated across multiple lines to import from multiple libraries or group symbols. Scoped origin resolution ensures that if multiple loaded libraries define relations with the same name (such as `inc` in `lib/bits.k` for bit trees vs. `inc` in `lib/arithmetics.k` for signed integers), the directive binds to the definition authored in `<dependency-path>`. This avoids hardcoding content hashes (`@hash`) in source files. See [file formats and tools](FILE_FORMATS.md#source-header-directives---lib-----use---) for complete details.
55
+
39
56
  ## Pattern syntax
40
57
 
41
58
  Patterns describe schema constraints rather than computations:
package/DOCS/REPL.md CHANGED
@@ -48,17 +48,23 @@ Regular evaluations include timing; there is no separate timing command.
48
48
  ## Loading and aliases
49
49
 
50
50
  ```text
51
- :load Examples/arithmetics.k
51
+ :load lib/bit.k
52
+ :load lib/bits.k
53
+ :load lib/arithmetics.k
54
+ :load lib/list.k
52
55
  :load Examples/poly.k
53
56
  ```
54
57
 
55
58
  Libraries are loaded explicitly. `poly.k` depends on definitions in
56
- `arithmetics.k`, so load them in that order. Loading a codec does not
57
- automatically load its corresponding k library.
59
+ `lib/arithmetics.k` and `lib/list.k`, so load them in dependency order. Loading
60
+ a codec does not automatically load its corresponding k library.
58
61
 
59
62
  `:load` compiles a `.k` file in the current library context or loads a plain
60
- JSON `.klib`. It recovers relation and pattern aliases unless `--no-alias`
61
- is specified. Source libraries' terminal expressions are not run by `:load`.
63
+ JSON `.klib`. When compiling a `.k` file, it reads any `# --lib <path> --use <specs>`
64
+ header directives in the leading comment block and resolves them against the
65
+ loaded libraries in the session. It recovers relation and pattern aliases
66
+ unless `--no-alias` is specified. Source libraries' terminal expressions are not
67
+ run by `:load`.
62
68
 
63
69
  Names are local aliases for canonical definitions. Rebinding a relation alias
64
70
  leaves older definitions addressable by hash in the live session.
@@ -90,8 +96,8 @@ See [patterns and canonical identity](PATTERNS.md).
90
96
  inc
91
97
  ```
92
98
 
93
- Load `Examples/arithmetics.k` before using `inc`. The codec supplies the
94
- integer value; the library supplies the relation.
99
+ Load `lib/bit.k`, `lib/bits.k`, and `lib/arithmetics.k` before using `inc`.
100
+ The codec supplies the integer value; the library supplies the relation.
95
101
 
96
102
  Codecs export `parse` and `print`. Input uses the codec explicitly selected
97
103
  with `:input`. When the text is omitted, the next line is parsed as external