@hviana/sema 0.1.4 → 0.1.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.
- package/dist/example/demo.js +25 -25
- package/dist/example/train_base.d.ts +21 -19
- package/dist/example/train_base.js +1952 -1684
- package/dist/src/alphabet.d.ts +3 -3
- package/dist/src/alphabet.js +27 -24
- package/dist/src/alu/src/alu.d.ts +194 -169
- package/dist/src/alu/src/alu.js +414 -374
- package/dist/src/alu/src/expr.d.ts +43 -36
- package/dist/src/alu/src/expr.js +278 -252
- package/dist/src/alu/src/index.d.ts +98 -9
- package/dist/src/alu/src/index.js +63 -9
- package/dist/src/alu/src/kernel-arith.d.ts +5 -1
- package/dist/src/alu/src/kernel-arith.js +285 -195
- package/dist/src/alu/src/kernel-bits.d.ts +5 -1
- package/dist/src/alu/src/kernel-bits.js +115 -81
- package/dist/src/alu/src/kernel-logic.js +63 -33
- package/dist/src/alu/src/kernel-nd.js +195 -155
- package/dist/src/alu/src/kernel-numeric.d.ts +80 -16
- package/dist/src/alu/src/kernel-numeric.js +331 -259
- package/dist/src/alu/src/operation.d.ts +132 -112
- package/dist/src/alu/src/operation.js +163 -149
- package/dist/src/alu/src/parser.d.ts +175 -168
- package/dist/src/alu/src/parser.js +421 -382
- package/dist/src/alu/src/resonance.d.ts +25 -16
- package/dist/src/alu/src/resonance.js +56 -49
- package/dist/src/alu/src/text.d.ts +7 -3
- package/dist/src/alu/src/text.js +37 -31
- package/dist/src/alu/src/value.d.ts +14 -14
- package/dist/src/alu/src/value.js +160 -150
- package/dist/src/alu/test/alu.test.js +656 -543
- package/dist/src/bytes.d.ts +5 -1
- package/dist/src/bytes.js +40 -33
- package/dist/src/config.d.ts +102 -102
- package/dist/src/config.js +83 -83
- package/dist/src/derive/src/deduction.d.ts +62 -60
- package/dist/src/derive/src/deduction.js +109 -103
- package/dist/src/derive/src/index.d.ts +7 -1
- package/dist/src/derive/src/priority-queue.d.ts +8 -8
- package/dist/src/derive/src/priority-queue.js +61 -57
- package/dist/src/derive/src/rewrite.d.ts +18 -15
- package/dist/src/derive/src/rewrite.js +67 -59
- package/dist/src/derive/src/trie.d.ts +56 -56
- package/dist/src/derive/src/trie.js +179 -175
- package/dist/src/derive/test/derive.test.js +100 -96
- package/dist/src/extension.d.ts +16 -13
- package/dist/src/geometry.d.ts +42 -17
- package/dist/src/geometry.js +266 -235
- package/dist/src/index.d.ts +17 -2
- package/dist/src/index.js +7 -1
- package/dist/src/ingest-cache.d.ts +30 -25
- package/dist/src/ingest-cache.js +127 -108
- package/dist/src/mind/articulation.d.ts +5 -1
- package/dist/src/mind/articulation.js +112 -77
- package/dist/src/mind/attention.d.ts +108 -40
- package/dist/src/mind/attention.js +871 -749
- package/dist/src/mind/canonical.d.ts +19 -4
- package/dist/src/mind/canonical.js +31 -27
- package/dist/src/mind/graph-search.d.ts +225 -201
- package/dist/src/mind/graph-search.js +821 -742
- package/dist/src/mind/index.d.ts +10 -2
- package/dist/src/mind/junction.d.ts +58 -31
- package/dist/src/mind/junction.js +237 -172
- package/dist/src/mind/learning.d.ts +52 -16
- package/dist/src/mind/learning.js +165 -143
- package/dist/src/mind/match.d.ts +69 -20
- package/dist/src/mind/match.js +318 -259
- package/dist/src/mind/mechanisms/alu.js +16 -16
- package/dist/src/mind/mechanisms/cast.d.ts +13 -9
- package/dist/src/mind/mechanisms/cast.js +456 -363
- package/dist/src/mind/mechanisms/confluence.d.ts +12 -8
- package/dist/src/mind/mechanisms/confluence.js +183 -152
- package/dist/src/mind/mechanisms/cover.d.ts +8 -2
- package/dist/src/mind/mechanisms/cover.js +210 -148
- package/dist/src/mind/mechanisms/extraction.d.ts +34 -8
- package/dist/src/mind/mechanisms/extraction.js +288 -234
- package/dist/src/mind/mechanisms/recall.d.ts +10 -6
- package/dist/src/mind/mechanisms/recall.js +185 -126
- package/dist/src/mind/mind.d.ts +154 -129
- package/dist/src/mind/mind.js +288 -258
- package/dist/src/mind/pipeline-mechanism.d.ts +124 -112
- package/dist/src/mind/pipeline-mechanism.js +172 -161
- package/dist/src/mind/pipeline.d.ts +14 -4
- package/dist/src/mind/pipeline.js +189 -125
- package/dist/src/mind/primitives.d.ts +32 -8
- package/dist/src/mind/primitives.js +117 -99
- package/dist/src/mind/rationale.d.ts +98 -86
- package/dist/src/mind/rationale.js +121 -113
- package/dist/src/mind/reasoning.d.ts +13 -2
- package/dist/src/mind/reasoning.js +166 -129
- package/dist/src/mind/recognition.d.ts +4 -1
- package/dist/src/mind/recognition.js +208 -183
- package/dist/src/mind/resonance.d.ts +22 -5
- package/dist/src/mind/resonance.js +0 -0
- package/dist/src/mind/trace.d.ts +25 -6
- package/dist/src/mind/trace.js +58 -50
- package/dist/src/mind/traverse.d.ts +58 -16
- package/dist/src/mind/traverse.js +357 -304
- package/dist/src/mind/types.d.ts +127 -120
- package/dist/src/mind/types.js +69 -60
- package/dist/src/rabitq-hnsw/src/database.d.ts +179 -177
- package/dist/src/rabitq-hnsw/src/database.js +359 -342
- package/dist/src/rabitq-hnsw/src/heap.d.ts +12 -12
- package/dist/src/rabitq-hnsw/src/heap.js +80 -75
- package/dist/src/rabitq-hnsw/src/hnsw.d.ts +103 -103
- package/dist/src/rabitq-hnsw/src/hnsw.js +454 -428
- package/dist/src/rabitq-hnsw/src/index.d.ts +6 -1
- package/dist/src/rabitq-hnsw/src/prng.d.ts +10 -10
- package/dist/src/rabitq-hnsw/src/prng.js +27 -25
- package/dist/src/rabitq-hnsw/src/rabitq.d.ts +69 -69
- package/dist/src/rabitq-hnsw/src/rabitq.js +262 -246
- package/dist/src/rabitq-hnsw/src/store.d.ts +132 -132
- package/dist/src/rabitq-hnsw/src/store.js +843 -752
- package/dist/src/rabitq-hnsw/test/hnsw.test.js +1054 -805
- package/dist/src/sema.d.ts +13 -9
- package/dist/src/sema.js +40 -26
- package/dist/src/store-sqlite.d.ts +166 -144
- package/dist/src/store-sqlite.js +660 -578
- package/dist/src/store.d.ts +630 -593
- package/dist/src/store.js +1581 -1440
- package/dist/src/vec.d.ts +9 -5
- package/dist/src/vec.js +73 -61
- package/package.json +2 -2
|
@@ -3,8 +3,8 @@ import type { ResonanceSync } from "./operation.js";
|
|
|
3
3
|
* surface forms, as bytes. The host resonates opaque spans against these to
|
|
4
4
|
* answer "which operation does this span MEAN?" (see parser.ts AluHost). */
|
|
5
5
|
export interface ConceptAnchor {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
name: string;
|
|
7
|
+
form: Uint8Array;
|
|
8
8
|
}
|
|
9
9
|
/** The async resonance capability the host provides. Both methods may return
|
|
10
10
|
* null when resonance finds nothing above the host's own threshold — ALU then
|
|
@@ -12,17 +12,17 @@ export interface ConceptAnchor {
|
|
|
12
12
|
* keeps synthesis graph-evidenced: ALU never invents meaning resonance did not
|
|
13
13
|
* supply. */
|
|
14
14
|
export interface AluResonance {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
15
|
+
/** The canonical operation a span's MEANING names, found by resonance over the
|
|
16
|
+
* operation concepts — the GENERIC, modality-agnostic recognition path. This
|
|
17
|
+
* is how an operation that is NOT literally spelled (no "∫" for an integral,
|
|
18
|
+
* no "+" for a sum drawn or spoken) is still recognised: the span's gist
|
|
19
|
+
* resonates with the operation's concept. Returns the canonical op name, or
|
|
20
|
+
* null when nothing resonates above threshold. */
|
|
21
|
+
recogniseOp(bytes: Uint8Array): Promise<string | null>;
|
|
22
|
+
/** The resonant opposite of a symbol's bytes (its antonym / inverse in the
|
|
23
|
+
* resonance space, any modality), or null. The host finds it by halo
|
|
24
|
+
* resonance over the negated concept. */
|
|
25
|
+
opposite(bytes: Uint8Array): Promise<Uint8Array | null>;
|
|
26
26
|
}
|
|
27
27
|
/** A AluResonance that knows nothing — the default when the host wires none in,
|
|
28
28
|
* so the kernel runs fully decoupled (operations resolve by literal forms only,
|
|
@@ -34,7 +34,10 @@ export declare const NO_ALU_RESONANCE: AluResonance;
|
|
|
34
34
|
* of the bytes (a lossless, stable string key — the same device the search's
|
|
35
35
|
* chart uses). This is the async→sync bridge for the polymorphic inverse,
|
|
36
36
|
* mirroring how a concept hop's target is pre-resolved and read synchronously. */
|
|
37
|
-
export declare function prefetchOpposites(
|
|
37
|
+
export declare function prefetchOpposites(
|
|
38
|
+
resonance: AluResonance,
|
|
39
|
+
symbols: Iterable<Uint8Array>,
|
|
40
|
+
): Promise<ResonanceSync>;
|
|
38
41
|
/** Pre-resolve BOTH capabilities a computation may need synchronously — the
|
|
39
42
|
* resonant opposite of a symbol (for the polymorphic inverse) AND the operation
|
|
40
43
|
* a symbol's MEANING names (for a higher-order nd op's function argument) — over
|
|
@@ -44,7 +47,10 @@ export declare function prefetchOpposites(resonance: AluResonance, symbols: Iter
|
|
|
44
47
|
* inverse operands and as a reduce/map/filter operator. Either lookup yields
|
|
45
48
|
* null for a span that resonates with nothing, so callbacks decline rather than
|
|
46
49
|
* guess. */
|
|
47
|
-
export declare function prefetchResonance(
|
|
50
|
+
export declare function prefetchResonance(
|
|
51
|
+
resonance: AluResonance,
|
|
52
|
+
spans: Iterable<Uint8Array>,
|
|
53
|
+
): Promise<ResonanceSync>;
|
|
48
54
|
/** Pre-resolve, for each candidate span, the operation its MEANING names —
|
|
49
55
|
* awaiting the host's async gist resonance once per distinct span — and return
|
|
50
56
|
* a synchronous map keyed by the span's latin1 bytes → canonical op name. This
|
|
@@ -52,4 +58,7 @@ export declare function prefetchResonance(resonance: AluResonance, spans: Iterab
|
|
|
52
58
|
* the literal scan could not classify (no operator symbol) but whose gist
|
|
53
59
|
* resonates with an operation's concept. Spans that resonate with nothing are
|
|
54
60
|
* omitted, so the caller treats a miss as "not an operation". */
|
|
55
|
-
export declare function prefetchRecognisedOps(
|
|
61
|
+
export declare function prefetchRecognisedOps(
|
|
62
|
+
resonance: AluResonance,
|
|
63
|
+
spans: Iterable<Uint8Array>,
|
|
64
|
+
): Promise<Map<string, string>>;
|
|
@@ -43,8 +43,8 @@ import { latin1 } from "../../bytes.js";
|
|
|
43
43
|
* so the kernel runs fully decoupled (operations resolve by literal forms only,
|
|
44
44
|
* and a symbol inverse is left unchanged). */
|
|
45
45
|
export const NO_ALU_RESONANCE = {
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
recogniseOp: async () => null,
|
|
47
|
+
opposite: async () => null,
|
|
48
48
|
};
|
|
49
49
|
/** Pre-resolve the resonant opposite of each symbol in `symbols`, awaiting the
|
|
50
50
|
* host's async resonance once per distinct span, and return a SYNCHRONOUS
|
|
@@ -53,23 +53,25 @@ export const NO_ALU_RESONANCE = {
|
|
|
53
53
|
* chart uses). This is the async→sync bridge for the polymorphic inverse,
|
|
54
54
|
* mirroring how a concept hop's target is pre-resolved and read synchronously. */
|
|
55
55
|
export async function prefetchOpposites(resonance, symbols) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
seen.add(key);
|
|
63
|
-
const opp = await resonance.opposite(bytes);
|
|
64
|
-
if (opp)
|
|
65
|
-
table.set(key, opp);
|
|
56
|
+
const table = new Map();
|
|
57
|
+
const seen = new Set();
|
|
58
|
+
for (const bytes of symbols) {
|
|
59
|
+
const key = latin1(bytes);
|
|
60
|
+
if (seen.has(key)) {
|
|
61
|
+
continue;
|
|
66
62
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
seen.add(key);
|
|
64
|
+
const opp = await resonance.opposite(bytes);
|
|
65
|
+
if (opp) {
|
|
66
|
+
table.set(key, opp);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
opposite: (bytes) => table.get(latin1(bytes)) ?? null,
|
|
71
|
+
// Opposites-only prefetch carries no op recognition; a higher-order nd op
|
|
72
|
+
// resolving through this falls back to literal forms / canonical names.
|
|
73
|
+
recogniseOp: () => null,
|
|
74
|
+
};
|
|
73
75
|
}
|
|
74
76
|
/** Pre-resolve BOTH capabilities a computation may need synchronously — the
|
|
75
77
|
* resonant opposite of a symbol (for the polymorphic inverse) AND the operation
|
|
@@ -81,27 +83,30 @@ export async function prefetchOpposites(resonance, symbols) {
|
|
|
81
83
|
* null for a span that resonates with nothing, so callbacks decline rather than
|
|
82
84
|
* guess. */
|
|
83
85
|
export async function prefetchResonance(resonance, spans) {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
ops.set(key, op);
|
|
86
|
+
const opposites = new Map();
|
|
87
|
+
const ops = new Map();
|
|
88
|
+
const seen = new Set();
|
|
89
|
+
for (const bytes of spans) {
|
|
90
|
+
const key = latin1(bytes);
|
|
91
|
+
if (seen.has(key)) {
|
|
92
|
+
continue;
|
|
93
|
+
}
|
|
94
|
+
seen.add(key);
|
|
95
|
+
const [opp, op] = await Promise.all([
|
|
96
|
+
resonance.opposite(bytes),
|
|
97
|
+
resonance.recogniseOp(bytes),
|
|
98
|
+
]);
|
|
99
|
+
if (opp) {
|
|
100
|
+
opposites.set(key, opp);
|
|
100
101
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
if (op) {
|
|
103
|
+
ops.set(key, op);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return {
|
|
107
|
+
opposite: (bytes) => opposites.get(latin1(bytes)) ?? null,
|
|
108
|
+
recogniseOp: (bytes) => ops.get(latin1(bytes)) ?? null,
|
|
109
|
+
};
|
|
105
110
|
}
|
|
106
111
|
/** Pre-resolve, for each candidate span, the operation its MEANING names —
|
|
107
112
|
* awaiting the host's async gist resonance once per distinct span — and return
|
|
@@ -111,16 +116,18 @@ export async function prefetchResonance(resonance, spans) {
|
|
|
111
116
|
* resonates with an operation's concept. Spans that resonate with nothing are
|
|
112
117
|
* omitted, so the caller treats a miss as "not an operation". */
|
|
113
118
|
export async function prefetchRecognisedOps(resonance, spans) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
const table = new Map();
|
|
120
|
+
const seen = new Set();
|
|
121
|
+
for (const bytes of spans) {
|
|
122
|
+
const key = latin1(bytes);
|
|
123
|
+
if (seen.has(key)) {
|
|
124
|
+
continue;
|
|
125
|
+
}
|
|
126
|
+
seen.add(key);
|
|
127
|
+
const op = await resonance.recogniseOp(bytes);
|
|
128
|
+
if (op) {
|
|
129
|
+
table.set(key, op);
|
|
124
130
|
}
|
|
125
|
-
|
|
131
|
+
}
|
|
132
|
+
return table;
|
|
126
133
|
}
|
|
@@ -25,7 +25,11 @@ export declare function matchBracket(b: Uint8Array, open: number): number;
|
|
|
25
25
|
/** The maximal non-whitespace runs of `bytes` within [from, to) — the spacing
|
|
26
26
|
* floor's reading of "the tokens", shared by the structural host's segmenter
|
|
27
27
|
* and the parser's term lexing so neither re-implements the walk. */
|
|
28
|
-
export declare function nonSpaceRuns(
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export declare function nonSpaceRuns(
|
|
29
|
+
bytes: Uint8Array,
|
|
30
|
+
from?: number,
|
|
31
|
+
to?: number,
|
|
32
|
+
): Array<{
|
|
33
|
+
i: number;
|
|
34
|
+
j: number;
|
|
31
35
|
}>;
|
package/dist/src/alu/src/text.js
CHANGED
|
@@ -18,56 +18,62 @@ export const OPEN = 0x5b; // "["
|
|
|
18
18
|
export const CLOSE = 0x5d; // "]"
|
|
19
19
|
/** ASCII whitespace (space, tab, newline, carriage return) — the one spacing
|
|
20
20
|
* convention bytes of every textual modality share. */
|
|
21
|
-
export const isSpaceByte = (c) =>
|
|
21
|
+
export const isSpaceByte = (c) =>
|
|
22
|
+
c === 0x20 || c === 0x09 || c === 0x0a || c === 0x0d;
|
|
22
23
|
/** A byte that DELIMITS list elements inside an explicit container: whitespace,
|
|
23
24
|
* a comma, or a semicolon. Deliberately excludes anything that can sit inside
|
|
24
25
|
* a numeral or a symbol token (letters, digits, sign/decimal `+ - .`) and the
|
|
25
26
|
* brackets themselves, so an element's own bytes are never split. */
|
|
26
|
-
export const isSepByte = (c) =>
|
|
27
|
+
export const isSepByte = (c) =>
|
|
28
|
+
isSpaceByte(c) || c === 0x2c /* , */ || c === 0x3b /* ; */;
|
|
27
29
|
/** The index of the first non-whitespace byte (or the length, if all space). */
|
|
28
30
|
export function trimStart(b) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
let i = 0;
|
|
32
|
+
while (i < b.length && isSpaceByte(b[i])) {
|
|
33
|
+
i++;
|
|
34
|
+
}
|
|
35
|
+
return i;
|
|
33
36
|
}
|
|
34
37
|
/** The index one past the last non-whitespace byte (or 0, if all space). */
|
|
35
38
|
export function trimEnd(b) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
let j = b.length;
|
|
40
|
+
const lo = trimStart(b);
|
|
41
|
+
while (j > lo && isSpaceByte(b[j - 1])) {
|
|
42
|
+
j--;
|
|
43
|
+
}
|
|
44
|
+
return j;
|
|
41
45
|
}
|
|
42
46
|
/** The index of the `]` matching the `[` at `open`, bracket-depth aware, or -1
|
|
43
47
|
* when it is unbalanced — used to test whether a span is one explicit list
|
|
44
48
|
* CONTAINER (its opening bracket closing exactly at its end). */
|
|
45
49
|
export function matchBracket(b, open) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
let depth = 0;
|
|
51
|
+
for (let i = open; i < b.length; i++) {
|
|
52
|
+
if (b[i] === OPEN) {
|
|
53
|
+
depth++;
|
|
54
|
+
} else if (b[i] === CLOSE && --depth === 0) {
|
|
55
|
+
return i;
|
|
52
56
|
}
|
|
53
|
-
|
|
57
|
+
}
|
|
58
|
+
return -1;
|
|
54
59
|
}
|
|
55
60
|
/** The maximal non-whitespace runs of `bytes` within [from, to) — the spacing
|
|
56
61
|
* floor's reading of "the tokens", shared by the structural host's segmenter
|
|
57
62
|
* and the parser's term lexing so neither re-implements the walk. */
|
|
58
63
|
export function nonSpaceRuns(bytes, from = 0, to = bytes.length) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
let j = i;
|
|
67
|
-
while (j < to && !isSpaceByte(bytes[j]))
|
|
68
|
-
j++;
|
|
69
|
-
out.push({ i, j });
|
|
70
|
-
i = j;
|
|
64
|
+
const out = [];
|
|
65
|
+
let i = from;
|
|
66
|
+
while (i < to) {
|
|
67
|
+
if (isSpaceByte(bytes[i])) {
|
|
68
|
+
i++;
|
|
69
|
+
continue;
|
|
71
70
|
}
|
|
72
|
-
|
|
71
|
+
let j = i;
|
|
72
|
+
while (j < to && !isSpaceByte(bytes[j])) {
|
|
73
|
+
j++;
|
|
74
|
+
}
|
|
75
|
+
out.push({ i, j });
|
|
76
|
+
i = j;
|
|
77
|
+
}
|
|
78
|
+
return out;
|
|
73
79
|
}
|
|
@@ -6,20 +6,20 @@ export type Domain = "bit" | "int" | "real" | "symbol" | "nd";
|
|
|
6
6
|
* Values of any domain, so nesting (a matrix = an nd of nd) and heterogeneity
|
|
7
7
|
* (a list mixing numbers, symbols, sub-lists) are the same case. */
|
|
8
8
|
export type Value = {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
domain: "bit";
|
|
10
|
+
b: 0 | 1;
|
|
11
11
|
} | {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
domain: "int";
|
|
13
|
+
n: bigint;
|
|
14
14
|
} | {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
domain: "real";
|
|
16
|
+
x: number;
|
|
17
17
|
} | {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
domain: "symbol";
|
|
19
|
+
bytes: Uint8Array;
|
|
20
20
|
} | {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
domain: "nd";
|
|
22
|
+
items: Value[];
|
|
23
23
|
};
|
|
24
24
|
export declare const bit: (b: 0 | 1) => Value;
|
|
25
25
|
export declare const int: (n: bigint) => Value;
|
|
@@ -36,8 +36,8 @@ export declare const tagOf: (v: Value) => Domain;
|
|
|
36
36
|
export declare function isNumeric(v: Value): boolean;
|
|
37
37
|
/** Whether a value is the n-dimensional container. */
|
|
38
38
|
export declare function isNd(v: Value): v is {
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
domain: "nd";
|
|
40
|
+
items: Value[];
|
|
41
41
|
};
|
|
42
42
|
/** Collect, into `out`, every SYMBOL byte span reachable inside a value — itself
|
|
43
43
|
* when it is a symbol, or each element recursively when it is an nd. These are
|
|
@@ -70,8 +70,8 @@ export declare function joinDomain(args: Value[]): "bit" | "int" | "real";
|
|
|
70
70
|
* bytes only through this, so the surrounding system owns how a number is
|
|
71
71
|
* spelled. A default ({@link decimalCodec}) is provided. */
|
|
72
72
|
export interface ValueCodec {
|
|
73
|
-
|
|
74
|
-
|
|
73
|
+
encode(v: Value): Uint8Array;
|
|
74
|
+
decode(bytes: Uint8Array): Value | null;
|
|
75
75
|
}
|
|
76
76
|
/** Parse a byte span into a SCALAR value: a clean integer numeral → exact int, a
|
|
77
77
|
* fractional/exponent numeral → real, anything else → a symbol carrying its
|