@mark1russell7/coeval 0.25.1 → 0.26.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/README.md +1 -0
- package/build/index.d.ts +178 -5
- package/build/index.d.ts.map +1 -1
- package/build/index.js +1247 -109
- package/build/index.js.map +1 -1
- package/package.json +4 -1
- package/src/agree.ts +10 -5
- package/src/facts.ts +17 -6
- package/src/formula.ts +11 -2
- package/src/generate.ts +4 -9
- package/src/index.ts +1 -0
- package/src/stepper.ts +1150 -0
package/build/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { mulberry32 } from "@mark1russell7/rigor-generators";
|
|
1
2
|
// src/doc.ts
|
|
2
3
|
/** The keys that an envelope can have. */
|
|
3
4
|
const ENVELOPE_KEYS = [
|
|
@@ -567,7 +568,7 @@ function effectsOfVerb(kind, verb) {
|
|
|
567
568
|
return table !== void 0 && Object.hasOwn(table, verb) ? table[verb] : void 0;
|
|
568
569
|
}
|
|
569
570
|
/** The most aliases that one lookup follows (WORLD.ALIAS-LIMIT). */
|
|
570
|
-
const MAX_ALIASES = 32;
|
|
571
|
+
const MAX_ALIASES$1 = 32;
|
|
571
572
|
/** This function tells if two paths of a lookup have the same keys. */
|
|
572
573
|
function samePath(a, b) {
|
|
573
574
|
if (a.length !== b.length) return false;
|
|
@@ -695,7 +696,7 @@ function lookupKind(world, type) {
|
|
|
695
696
|
}
|
|
696
697
|
if (isAlias(entry)) {
|
|
697
698
|
aliases += 1;
|
|
698
|
-
if (aliases > MAX_ALIASES) return {
|
|
699
|
+
if (aliases > MAX_ALIASES$1) return {
|
|
699
700
|
ok: false,
|
|
700
701
|
reason: "too-long",
|
|
701
702
|
path
|
|
@@ -1689,7 +1690,7 @@ function itemOf(type, domains) {
|
|
|
1689
1690
|
return form.t === "list" ? form.item : void 0;
|
|
1690
1691
|
}
|
|
1691
1692
|
/** This function gives the type of a field of a record type, or `undefined` when the type is not a record with the field. */
|
|
1692
|
-
function fieldOf(type, key, domains) {
|
|
1693
|
+
function fieldOf$1(type, key, domains) {
|
|
1693
1694
|
const form = formOf(type, domains);
|
|
1694
1695
|
return form.t === "record" && Object.hasOwn(form.fields, key) ? form.fields[key] : void 0;
|
|
1695
1696
|
}
|
|
@@ -1956,7 +1957,7 @@ function setOwn$5(target, key, value) {
|
|
|
1956
1957
|
});
|
|
1957
1958
|
else target[key] = value;
|
|
1958
1959
|
}
|
|
1959
|
-
function own$
|
|
1960
|
+
function own$3(table, key) {
|
|
1960
1961
|
return table !== void 0 && Object.hasOwn(table, key) ? table[key] : void 0;
|
|
1961
1962
|
}
|
|
1962
1963
|
/** This function gives a copy of a JSON value without the fields whose value is `undefined`, as JSON writes it. */
|
|
@@ -2010,7 +2011,7 @@ function sameDomain(a, b) {
|
|
|
2010
2011
|
*/
|
|
2011
2012
|
function extendDomain(name, more) {
|
|
2012
2013
|
return (prev) => {
|
|
2013
|
-
const found = own$
|
|
2014
|
+
const found = own$3(prev.domains, name) ?? own$3(STD_DOMAINS, name);
|
|
2014
2015
|
if (typeof found !== "object" || found === null || typeof found.is !== "function") return {};
|
|
2015
2016
|
const under = [...found.under ?? []];
|
|
2016
2017
|
for (const parent of more.under ?? []) if (parent !== name && !under.includes(parent)) under.push(parent);
|
|
@@ -2081,7 +2082,7 @@ var Merger = class {
|
|
|
2081
2082
|
*/
|
|
2082
2083
|
function mergeLeaf(m, table, key, later, path, part, replaces, equal, reason) {
|
|
2083
2084
|
if (later === void 0) return;
|
|
2084
|
-
const earlier = own$
|
|
2085
|
+
const earlier = own$3(table, key);
|
|
2085
2086
|
if (earlier === void 0) {
|
|
2086
2087
|
setOwn$5(table, key, later);
|
|
2087
2088
|
m.give(path, part);
|
|
@@ -2105,7 +2106,7 @@ function mergeEntries(m, into, from, path, part, replaces) {
|
|
|
2105
2106
|
const later = from[key];
|
|
2106
2107
|
if (later === void 0) continue;
|
|
2107
2108
|
const at = [...path, key];
|
|
2108
|
-
const earlier = own$
|
|
2109
|
+
const earlier = own$3(into, key);
|
|
2109
2110
|
if (earlier === void 0) {
|
|
2110
2111
|
setOwn$5(into, key, later);
|
|
2111
2112
|
m.give(at, part);
|
|
@@ -2152,7 +2153,7 @@ function changeKind(table, path, change) {
|
|
|
2152
2153
|
fallback: change(table.fallback)
|
|
2153
2154
|
};
|
|
2154
2155
|
if (String(first) !== "kinds" || key === void 0) return void 0;
|
|
2155
|
-
const entry = own$
|
|
2156
|
+
const entry = own$3(table.kinds, String(key));
|
|
2156
2157
|
const next = rest.length === 0 ? isKind(entry) ? change(entry) : void 0 : isNamespace(entry) ? changeKind(entry, rest, change) : void 0;
|
|
2157
2158
|
if (next === void 0) return void 0;
|
|
2158
2159
|
const kinds = { ...table.kinds };
|
|
@@ -2178,7 +2179,7 @@ function addVerbs(draft, m) {
|
|
|
2178
2179
|
}
|
|
2179
2180
|
const next = changeKind(table, entry.kind, (kind) => {
|
|
2180
2181
|
const verbs = { ...kind.verbs };
|
|
2181
|
-
const earlier = own$
|
|
2182
|
+
const earlier = own$3(verbs, entry.verb);
|
|
2182
2183
|
if (earlier === void 0) m?.give(entry.path, entry.part);
|
|
2183
2184
|
else if (entry.replaced) m?.replace(entry.path, entry.part);
|
|
2184
2185
|
else if (earlier !== entry.code) m?.clash(entry.path, entry.part, "Two parts give two different evaluators for this verb of this kind.");
|
|
@@ -2363,8 +2364,8 @@ function mergeCode(m, draft, part, index, replaces) {
|
|
|
2363
2364
|
if (part.runners !== void 0) draft.runners ??= {};
|
|
2364
2365
|
const names = /* @__PURE__ */ new Set([...Object.keys(part.evaluators ?? {}), ...Object.keys(part.runners ?? {})]);
|
|
2365
2366
|
for (const name of names) {
|
|
2366
|
-
const evaluator = own$
|
|
2367
|
-
const runner = own$
|
|
2367
|
+
const evaluator = own$3(part.evaluators, name);
|
|
2368
|
+
const runner = own$3(part.runners, name);
|
|
2368
2369
|
if (evaluator === void 0 && runner === void 0) continue;
|
|
2369
2370
|
const evaluatorPath = ["evaluators", name];
|
|
2370
2371
|
const runnerPath = ["runners", name];
|
|
@@ -2387,9 +2388,9 @@ function checkHidden(m, draft) {
|
|
|
2387
2388
|
const runners = draft.runners ?? {};
|
|
2388
2389
|
for (const name of Object.keys(runners)) {
|
|
2389
2390
|
const runner = runners[name];
|
|
2390
|
-
const evaluator = own$
|
|
2391
|
+
const evaluator = own$3(draft.evaluators, name);
|
|
2391
2392
|
if (runner === void 0 || evaluator === void 0) continue;
|
|
2392
|
-
if (draft.parts.some((part) => own$
|
|
2393
|
+
if (draft.parts.some((part) => own$3(part.evaluators, name) === evaluator && own$3(part.runners, name) === runner)) continue;
|
|
2393
2394
|
const a = m.sourceOf(["evaluators", name]);
|
|
2394
2395
|
const b = m.sourceOf(["runners", name]);
|
|
2395
2396
|
m.conflicts.push({
|
|
@@ -2472,7 +2473,7 @@ function removeEntry(entries, path) {
|
|
|
2472
2473
|
const [first, ...rest] = path;
|
|
2473
2474
|
if (first === void 0) return entries;
|
|
2474
2475
|
const key = String(first);
|
|
2475
|
-
const entry = own$
|
|
2476
|
+
const entry = own$3(entries, key);
|
|
2476
2477
|
if (entry === void 0) return entries;
|
|
2477
2478
|
let next;
|
|
2478
2479
|
if (rest.length > 0) {
|
|
@@ -3217,7 +3218,7 @@ function context(parts = {}) {
|
|
|
3217
3218
|
caps: parts.caps ?? []
|
|
3218
3219
|
};
|
|
3219
3220
|
}
|
|
3220
|
-
const MAX_COLLAPSE = 64;
|
|
3221
|
+
const MAX_COLLAPSE$1 = 64;
|
|
3221
3222
|
/** The reason of a resolution that reaches the bound of collapses without a cycle that it found (DEREF.CHAIN-REASON). It is a plain string, thus a bundle drops it (PKG.PURE). */
|
|
3222
3223
|
const CHAIN_REASON = "The path follows more than 64 references. One resolution follows at most 64.";
|
|
3223
3224
|
const NO_HOPS$1 = /* @__PURE__ */ Object.freeze([]);
|
|
@@ -3448,7 +3449,7 @@ function resolveFully$1(nav, ctx, path, hops, known) {
|
|
|
3448
3449
|
while (isRef(here)) {
|
|
3449
3450
|
if (open?.includes(here) === true) return failed("#CYCLE!", "The references form a cycle.");
|
|
3450
3451
|
collapses += 1;
|
|
3451
|
-
if (collapses > MAX_COLLAPSE) return failed("#CYCLE!", CHAIN_REASON);
|
|
3452
|
+
if (collapses > MAX_COLLAPSE$1) return failed("#CYCLE!", CHAIN_REASON);
|
|
3452
3453
|
open ??= [];
|
|
3453
3454
|
open.push(here);
|
|
3454
3455
|
const inner = walk(here.value, void 0);
|
|
@@ -3599,7 +3600,7 @@ function tag(value, kind) {
|
|
|
3599
3600
|
return typed(kind, value);
|
|
3600
3601
|
}
|
|
3601
3602
|
// src/parts.ts
|
|
3602
|
-
var Bad = class {
|
|
3603
|
+
var Bad$1 = class {
|
|
3603
3604
|
reason;
|
|
3604
3605
|
at;
|
|
3605
3606
|
constructor(reason, at) {
|
|
@@ -3647,7 +3648,7 @@ function kindFault(kinds, item, of, path) {
|
|
|
3647
3648
|
const type = isEnvelope(item) ? typePath(item.type) : of === void 0 ? void 0 : [of];
|
|
3648
3649
|
if (type !== void 0 && kinds.some((kind) => kind.length <= type.length && kind.every((key, index) => String(key) === String(type[index])))) return;
|
|
3649
3650
|
const names = kinds.map((kind) => kind.join(".")).join(", ");
|
|
3650
|
-
throw new Bad(`${isEnvelope(item) ? `The kind ${typeName(item.type)} is not permitted here.` : "A value without an envelope is not permitted here."} The permitted kinds are ${names}.`, path);
|
|
3651
|
+
throw new Bad$1(`${isEnvelope(item) ? `The kind ${typeName(item.type)} is not permitted here.` : "A value without an envelope is not permitted here."} The permitted kinds are ${names}.`, path);
|
|
3651
3652
|
}
|
|
3652
3653
|
/**
|
|
3653
3654
|
* This function splits a value into its parts, by the shape that its kind declares. The evaluator, the view and
|
|
@@ -3713,7 +3714,7 @@ function splitParts(shape, value) {
|
|
|
3713
3714
|
};
|
|
3714
3715
|
if (spec.shape === "text" || spec.shape === "number" || spec.shape === "one") {
|
|
3715
3716
|
const reason = dataFault(spec, item);
|
|
3716
|
-
if (reason !== void 0) throw new Bad(reason, path);
|
|
3717
|
+
if (reason !== void 0) throw new Bad$1(reason, path);
|
|
3717
3718
|
return {
|
|
3718
3719
|
t: "data",
|
|
3719
3720
|
value: item
|
|
@@ -3725,11 +3726,11 @@ function splitParts(shape, value) {
|
|
|
3725
3726
|
}
|
|
3726
3727
|
if (spec.shape === "deep") return deep(item, path, spec.of, spec.expect);
|
|
3727
3728
|
if (spec.shape === "list") {
|
|
3728
|
-
if (!Array.isArray(item)) throw new Bad("The value must be a list.", path);
|
|
3729
|
+
if (!Array.isArray(item)) throw new Bad$1("The value must be a list.", path);
|
|
3729
3730
|
const list = item;
|
|
3730
3731
|
if (spec.distinct === true) {
|
|
3731
3732
|
const twice = list.findIndex((child, index) => list.slice(0, index).some((before) => docEquals(before, child)));
|
|
3732
|
-
if (twice !== -1) throw new Bad("The items of the list must be different.", [...path, twice]);
|
|
3733
|
+
if (twice !== -1) throw new Bad$1("The items of the list must be different.", [...path, twice]);
|
|
3733
3734
|
}
|
|
3734
3735
|
const each = spec.item ?? termOf$1(spec.of, spec.expect);
|
|
3735
3736
|
const items = list.map((child, index) => walk(each, child, [...path, index]));
|
|
@@ -3741,7 +3742,7 @@ function splitParts(shape, value) {
|
|
|
3741
3742
|
items
|
|
3742
3743
|
};
|
|
3743
3744
|
}
|
|
3744
|
-
if (!isRecord(item)) throw new Bad("The value must be a record.", path);
|
|
3745
|
+
if (!isRecord(item)) throw new Bad$1("The value must be a record.", path);
|
|
3745
3746
|
if (spec.shape === "map") {
|
|
3746
3747
|
const each = spec.item ?? termOf$1(spec.of, spec.expect);
|
|
3747
3748
|
return {
|
|
@@ -3749,11 +3750,11 @@ function splitParts(shape, value) {
|
|
|
3749
3750
|
fields: Object.keys(item).map((key) => [key, walk(each, item[key], [...path, key])])
|
|
3750
3751
|
};
|
|
3751
3752
|
}
|
|
3752
|
-
for (const name of spec.required ?? []) if (!Object.hasOwn(item, name)) throw new Bad(`The field ${name} is missing.`, path);
|
|
3753
|
+
for (const name of spec.required ?? []) if (!Object.hasOwn(item, name)) throw new Bad$1(`The field ${name} is missing.`, path);
|
|
3753
3754
|
const named = Array.isArray(spec.fields) ? Object.fromEntries(spec.fields.map((name) => [name, termOf$1(spec.of, spec.expect)])) : spec.fields;
|
|
3754
3755
|
const fields = [];
|
|
3755
3756
|
for (const key of Object.keys(item)) {
|
|
3756
|
-
if (spec.closed === true && !Object.hasOwn(named, key)) throw new Bad(`The field ${key} is not a field of this kind.`, [...path, key]);
|
|
3757
|
+
if (spec.closed === true && !Object.hasOwn(named, key)) throw new Bad$1(`The field ${key} is not a field of this kind.`, [...path, key]);
|
|
3757
3758
|
const fieldShape = Object.hasOwn(named, key) ? named[key] : spec.rest;
|
|
3758
3759
|
fields.push([key, walk(fieldShape, item[key], [...path, key])]);
|
|
3759
3760
|
}
|
|
@@ -3766,7 +3767,7 @@ function splitParts(shape, value) {
|
|
|
3766
3767
|
try {
|
|
3767
3768
|
template = walk(shape, value, []);
|
|
3768
3769
|
} catch (error) {
|
|
3769
|
-
if (error instanceof Bad) return {
|
|
3770
|
+
if (error instanceof Bad$1) return {
|
|
3770
3771
|
ok: false,
|
|
3771
3772
|
reason: error.reason,
|
|
3772
3773
|
at: error.at
|
|
@@ -4687,7 +4688,7 @@ var Session = class {
|
|
|
4687
4688
|
if (this.running) return fail("#CALC!", `The effect ${text} needs a runner: in a run, the host does each effect.`, { place });
|
|
4688
4689
|
const frame = frameOf(ctx);
|
|
4689
4690
|
const clause = frame === void 0 ? void 0 : this.clauseOf(ctx, frame, kind, place);
|
|
4690
|
-
if (clause !== void 0) return "ok" in clause ? clause : drive$
|
|
4691
|
+
if (clause !== void 0) return "ok" in clause ? clause : drive$3(clause.answer(payload), text);
|
|
4691
4692
|
const made = this.record(ctx, kind, payload, place);
|
|
4692
4693
|
return "ok" in made ? made : this.answer(made, place);
|
|
4693
4694
|
}
|
|
@@ -4898,7 +4899,7 @@ function heldReason(kind) {
|
|
|
4898
4899
|
/** The wait of an effect that a run does not give to the host. A drive without a wait stops at it (RUN.HELD). */
|
|
4899
4900
|
const HELD = /* @__PURE__ */ Promise.resolve(void 0);
|
|
4900
4901
|
/** This function drives steps that cannot wait. A step that waits stops the steps, and gives `#CALC!`. */
|
|
4901
|
-
function drive$
|
|
4902
|
+
function drive$3(steps, kindText) {
|
|
4902
4903
|
const step = steps.next();
|
|
4903
4904
|
if (step.done === true) return step.value;
|
|
4904
4905
|
step.value.catch(() => void 0);
|
|
@@ -4947,13 +4948,13 @@ function failing(c, meta, place, code, reason) {
|
|
|
4947
4948
|
/** This function gives the code of a document that fails with one result at each evaluation. */
|
|
4948
4949
|
function failingWith(c, meta, result) {
|
|
4949
4950
|
const plain = () => result;
|
|
4950
|
-
return finish$
|
|
4951
|
+
return finish$2(c, meta, plain, void 0);
|
|
4951
4952
|
}
|
|
4952
4953
|
/**
|
|
4953
4954
|
* This function gives the code of a document in a trace. Each node records the context that its grant permits
|
|
4954
4955
|
* (CAP.NARROW-CODE), as the code of the document gets it.
|
|
4955
4956
|
*/
|
|
4956
|
-
function finish$
|
|
4957
|
+
function finish$2(c, meta, code, steps) {
|
|
4957
4958
|
if (!c.traced) return {
|
|
4958
4959
|
code,
|
|
4959
4960
|
run: steps
|
|
@@ -5111,7 +5112,7 @@ function compileNode(c, value, place, declared, depth, address = false) {
|
|
|
5111
5112
|
}
|
|
5112
5113
|
const guard = guardOf(c, place);
|
|
5113
5114
|
const run = placedRun(guard === void 0 ? inner : guardRun(inner, guard, c.machine.domains), place, name);
|
|
5114
|
-
return finish$
|
|
5115
|
+
return finish$2(c, meta, runnerCode(run, place, kindText), run);
|
|
5115
5116
|
}
|
|
5116
5117
|
let inner;
|
|
5117
5118
|
try {
|
|
@@ -5120,7 +5121,7 @@ function compileNode(c, value, place, declared, depth, address = false) {
|
|
|
5120
5121
|
return failingWith(c, meta, placed(thrown(error, `the evaluator ${name}`), place));
|
|
5121
5122
|
}
|
|
5122
5123
|
const guard = guardOf(c, place);
|
|
5123
|
-
const done = finish$
|
|
5124
|
+
const done = finish$2(c, meta, guard !== void 0 ? placedCode(guardCode(inner, guard, c.machine.domains), place, name) : TOTAL.has(inner) ? inner : placedCode(inner, place, name), void 0);
|
|
5124
5125
|
if (frees === void 0 || kind === void 0 || !pureCode(c, envelope, kind, typePath, name, quick)) return done;
|
|
5125
5126
|
const free = freeOf(doc, kind, split.parts, frees);
|
|
5126
5127
|
if (free === void 0) return done;
|
|
@@ -5556,10 +5557,10 @@ function placedRun(inner, place, name) {
|
|
|
5556
5557
|
*/
|
|
5557
5558
|
function runnerCode(run, place, kindText) {
|
|
5558
5559
|
return (ctx, rt) => {
|
|
5559
|
-
if (!rt.running || !(rt instanceof Session)) return placed(drive$
|
|
5560
|
+
if (!rt.running || !(rt instanceof Session)) return placed(drive$3(run(ctx, rt), kindText), place);
|
|
5560
5561
|
rt.held += 1;
|
|
5561
5562
|
try {
|
|
5562
|
-
return placed(drive$
|
|
5563
|
+
return placed(drive$3(run(ctx, rt), kindText), place);
|
|
5563
5564
|
} finally {
|
|
5564
5565
|
rt.held -= 1;
|
|
5565
5566
|
}
|
|
@@ -8630,7 +8631,8 @@ function codeFactsOf(machine, v, kind, verb) {
|
|
|
8630
8631
|
*
|
|
8631
8632
|
* - `reads`: each free reference, with the root and the keys of its path. A read under a lazy part has the mark
|
|
8632
8633
|
* `lazy`, for example a read in a branch of `if`. A read after a step document has `exact: false`. A kind that
|
|
8633
|
-
* declares `reads` adds a read of each of its roots at each document of the kind.
|
|
8634
|
+
* declares `reads` adds a read of each of its roots at each document of the kind. A reference with a step document
|
|
8635
|
+
* of the kind also has these reads (FACTS.STEP-READS). The first document of a tree
|
|
8634
8636
|
* kind also gets the lazy reads of the equations of its kind (FACTS.EQUATIONS). A read from `self` or from a name
|
|
8635
8637
|
* of a rung is not one of them, because it is not free (READS.EQUATION).
|
|
8636
8638
|
* - `side` and `effects`: from the contract of each kind, for the verb of the facts.
|
|
@@ -8677,6 +8679,26 @@ function factsOf(machine, doc, options = {}) {
|
|
|
8677
8679
|
if (options.volatile?.(read) === true) volatile = true;
|
|
8678
8680
|
};
|
|
8679
8681
|
/**
|
|
8682
|
+
* This function adds a read of each declared root at the place of a document (FACTS.KIND-READS, FACTS.STEP-READS).
|
|
8683
|
+
* It is one function for the facts, thus a visit makes no new function.
|
|
8684
|
+
*/
|
|
8685
|
+
const declare = (list, node, lazy, place) => {
|
|
8686
|
+
if (list === void 0) return;
|
|
8687
|
+
for (const root of list) {
|
|
8688
|
+
if (node !== void 0 && root === "self") continue;
|
|
8689
|
+
add({
|
|
8690
|
+
root,
|
|
8691
|
+
keys: NONE,
|
|
8692
|
+
exact: true,
|
|
8693
|
+
lazy,
|
|
8694
|
+
address: false,
|
|
8695
|
+
path: [root],
|
|
8696
|
+
place: tight(place.place),
|
|
8697
|
+
at: tight(place.at)
|
|
8698
|
+
});
|
|
8699
|
+
}
|
|
8700
|
+
};
|
|
8701
|
+
/**
|
|
8680
8702
|
* This function walks a document. Without `node`, it walks the document of the facts. With `node`, it walks an
|
|
8681
8703
|
* equation of a tree kind, and each read gets the place of that node: the first document of the kind.
|
|
8682
8704
|
*/
|
|
@@ -8708,19 +8730,7 @@ function factsOf(machine, doc, options = {}) {
|
|
|
8708
8730
|
note(answer?.pure, answer?.volatile);
|
|
8709
8731
|
roots = answer?.reads;
|
|
8710
8732
|
}
|
|
8711
|
-
|
|
8712
|
-
if (node !== void 0 && root === "self") continue;
|
|
8713
|
-
add({
|
|
8714
|
-
root,
|
|
8715
|
-
keys: NONE,
|
|
8716
|
-
exact: true,
|
|
8717
|
-
lazy,
|
|
8718
|
-
address: false,
|
|
8719
|
-
path: [root],
|
|
8720
|
-
place: tight(place.place),
|
|
8721
|
-
at: tight(place.at)
|
|
8722
|
-
});
|
|
8723
|
-
}
|
|
8733
|
+
declare(roots, node, lazy, place);
|
|
8724
8734
|
const declared = verb === "eval" && answer?.effects !== void 0 ? effectKeys(v, answer.effects) : declaredEffects(v, verb);
|
|
8725
8735
|
if (verb === "eval" ? kind.side === "run" : declared.length > 0) {
|
|
8726
8736
|
if (node === void 0) side = "run";
|
|
@@ -8765,6 +8775,7 @@ function factsOf(machine, doc, options = {}) {
|
|
|
8765
8775
|
const stepAnswer = walker.name === void 0 ? void 0 : hook?.(found.path, walker.name);
|
|
8766
8776
|
if (walker.described) note(stepAnswer?.pure ?? found.kind.pure, stepAnswer?.volatile ?? found.kind.volatile);
|
|
8767
8777
|
else note(stepAnswer?.pure, stepAnswer?.volatile);
|
|
8778
|
+
declare(stepAnswer?.reads ?? (walker.described ? found.kind.reads : void 0), node, lazy, place);
|
|
8768
8779
|
}
|
|
8769
8780
|
const first = path[1];
|
|
8770
8781
|
if (root === "names" && isKey(first) && v.names.has(String(first))) return void 0;
|
|
@@ -9797,7 +9808,7 @@ function withoutNames(options) {
|
|
|
9797
9808
|
return rest;
|
|
9798
9809
|
}
|
|
9799
9810
|
/** This function gives the keys of a trail, from its start. It keeps the result in the trail. */
|
|
9800
|
-
function keysOf(trail) {
|
|
9811
|
+
function keysOf$1(trail) {
|
|
9801
9812
|
if (trail === void 0) return [];
|
|
9802
9813
|
if (trail.full !== void 0) return trail.full;
|
|
9803
9814
|
const steps = [];
|
|
@@ -9856,10 +9867,10 @@ var Visit = class {
|
|
|
9856
9867
|
return this.#expect;
|
|
9857
9868
|
}
|
|
9858
9869
|
get place() {
|
|
9859
|
-
return keysOf(this.#place);
|
|
9870
|
+
return keysOf$1(this.#place);
|
|
9860
9871
|
}
|
|
9861
9872
|
get at() {
|
|
9862
|
-
return keysOf(this.#at);
|
|
9873
|
+
return keysOf$1(this.#at);
|
|
9863
9874
|
}
|
|
9864
9875
|
};
|
|
9865
9876
|
/**
|
|
@@ -9896,8 +9907,8 @@ function walk(world, doc, visit, options = {}) {
|
|
|
9896
9907
|
const read = partsOf(world, item.value, item.declared);
|
|
9897
9908
|
if (!read.ok) {
|
|
9898
9909
|
options.problem?.({
|
|
9899
|
-
place: keysOf(item.place),
|
|
9900
|
-
at: keysOf(item.at),
|
|
9910
|
+
place: keysOf$1(item.place),
|
|
9911
|
+
at: keysOf$1(item.at),
|
|
9901
9912
|
code: read.code,
|
|
9902
9913
|
reason: read.reason
|
|
9903
9914
|
});
|
|
@@ -9912,8 +9923,8 @@ function walk(world, doc, visit, options = {}) {
|
|
|
9912
9923
|
};
|
|
9913
9924
|
if (!split.ok) {
|
|
9914
9925
|
options.problem?.({
|
|
9915
|
-
place: keysOf(item.place),
|
|
9916
|
-
at: keysOf({
|
|
9926
|
+
place: keysOf$1(item.place),
|
|
9927
|
+
at: keysOf$1({
|
|
9917
9928
|
up: base,
|
|
9918
9929
|
keys: split.at
|
|
9919
9930
|
}),
|
|
@@ -11224,7 +11235,7 @@ var Held = class {
|
|
|
11224
11235
|
this.error = error;
|
|
11225
11236
|
}
|
|
11226
11237
|
};
|
|
11227
|
-
const CLOSURE$
|
|
11238
|
+
const CLOSURE$3 = /* @__PURE__ */ Symbol.for("coeval.closure");
|
|
11228
11239
|
/**
|
|
11229
11240
|
* This function tells if a value is a function that the construct `fn` made.
|
|
11230
11241
|
*
|
|
@@ -11232,7 +11243,7 @@ const CLOSURE$2 = /* @__PURE__ */ Symbol.for("coeval.closure");
|
|
|
11232
11243
|
* @returns `true` for a closure.
|
|
11233
11244
|
*/
|
|
11234
11245
|
function isClosure(value) {
|
|
11235
|
-
return typeof value === "function" && value[CLOSURE$
|
|
11246
|
+
return typeof value === "function" && value[CLOSURE$3] !== void 0;
|
|
11236
11247
|
}
|
|
11237
11248
|
/**
|
|
11238
11249
|
* The standard extensions: the values that JSON cannot write. `ext.domain` reads a member of a domain through the
|
|
@@ -11705,7 +11716,7 @@ function formulaTypes(profile) {
|
|
|
11705
11716
|
},
|
|
11706
11717
|
"formula.record": {
|
|
11707
11718
|
part: (input, path) => {
|
|
11708
|
-
const want = fieldOf(input.expected, String(path[0]), input.machine.domains);
|
|
11719
|
+
const want = fieldOf$1(input.expected, String(path[0]), input.machine.domains);
|
|
11709
11720
|
return want === void 0 ? {} : {
|
|
11710
11721
|
expect: want,
|
|
11711
11722
|
what: `field ${String(path[0])} of the record`
|
|
@@ -12026,6 +12037,7 @@ const PROFILE_KEYS = /* @__PURE__ */ Object.freeze([
|
|
|
12026
12037
|
"combine",
|
|
12027
12038
|
"pure",
|
|
12028
12039
|
"pureExt",
|
|
12040
|
+
"extReads",
|
|
12029
12041
|
"volatile",
|
|
12030
12042
|
"sigs"
|
|
12031
12043
|
]);
|
|
@@ -12280,7 +12292,7 @@ function formulaCode(profile) {
|
|
|
12280
12292
|
clock.applying = level - 1;
|
|
12281
12293
|
}
|
|
12282
12294
|
};
|
|
12283
|
-
Object.defineProperty(closure, CLOSURE$
|
|
12295
|
+
Object.defineProperty(closure, CLOSURE$3, { value: { params: names } });
|
|
12284
12296
|
return ok(closure);
|
|
12285
12297
|
};
|
|
12286
12298
|
}),
|
|
@@ -12495,7 +12507,14 @@ function makeFacts(profile, known) {
|
|
|
12495
12507
|
if (code !== "formula.op" && code !== "formula.ext") return void 0;
|
|
12496
12508
|
const name = path.slice(1).join(".");
|
|
12497
12509
|
if (code === "formula.ext") {
|
|
12498
|
-
if (profile.ext !== void 0 && Object.hasOwn(profile.ext, name))
|
|
12510
|
+
if (profile.ext !== void 0 && Object.hasOwn(profile.ext, name)) {
|
|
12511
|
+
const facts = pureExt.has(name) ? PURE : NOT_PURE;
|
|
12512
|
+
const reads = profile.extReads !== void 0 && Object.hasOwn(profile.extReads, name) ? profile.extReads[name] : void 0;
|
|
12513
|
+
return reads === void 0 ? facts : {
|
|
12514
|
+
...facts,
|
|
12515
|
+
reads
|
|
12516
|
+
};
|
|
12517
|
+
}
|
|
12499
12518
|
return Object.hasOwn(STD_EXT, name) ? PURE : void 0;
|
|
12500
12519
|
}
|
|
12501
12520
|
if (known(path, code) !== true) return void 0;
|
|
@@ -12541,7 +12560,7 @@ function formulaMachine(profile = {}, more = {}) {
|
|
|
12541
12560
|
}, more);
|
|
12542
12561
|
}
|
|
12543
12562
|
// src/reference.ts
|
|
12544
|
-
function own$
|
|
12563
|
+
function own$2(table, name) {
|
|
12545
12564
|
return table !== void 0 && Object.hasOwn(table, name) ? table[name] : void 0;
|
|
12546
12565
|
}
|
|
12547
12566
|
/**
|
|
@@ -12549,16 +12568,16 @@ function own$1(table, name) {
|
|
|
12549
12568
|
* evaluator gets the definition of the reference, unless the options give another definition (REF.TREE).
|
|
12550
12569
|
*/
|
|
12551
12570
|
function choose(env, name) {
|
|
12552
|
-
const runner = own$
|
|
12571
|
+
const runner = own$2(env.machine.runners, name);
|
|
12553
12572
|
if (runner !== void 0) {
|
|
12554
|
-
const defined = own$
|
|
12573
|
+
const defined = own$2(env.definitions.runners, name);
|
|
12555
12574
|
if (defined !== void 0) return { runner: defined };
|
|
12556
12575
|
return typeof runner === "function" ? { runner } : { gap: `The reference has no definition of the compiled runner ${name}.` };
|
|
12557
12576
|
}
|
|
12558
|
-
const evaluator = own$
|
|
12577
|
+
const evaluator = own$2(env.machine.evaluators, name);
|
|
12559
12578
|
if (evaluator === void 0) return void 0;
|
|
12560
|
-
const standard = evaluator === own$
|
|
12561
|
-
const defined = own$
|
|
12579
|
+
const standard = evaluator === own$2(STD_EVALUATORS, name) ? own$2(STD_DEFINITIONS.evaluators, name) : void 0;
|
|
12580
|
+
const defined = own$2(env.definitions.evaluators, name) ?? standard;
|
|
12562
12581
|
if (defined !== void 0) return { evaluator: defined };
|
|
12563
12582
|
return typeof evaluator === "function" ? { evaluator } : { gap: `The reference has no definition of the compiled evaluator ${name}.` };
|
|
12564
12583
|
}
|
|
@@ -12722,10 +12741,10 @@ function clauseAt(env, ctx, kind, place) {
|
|
|
12722
12741
|
* address (RUN.ADDRESS) and its outcome (RUN.OUTCOME). The mock answers the effect at once (RUN.MOCK). Without a
|
|
12723
12742
|
* mock, the effect gives its payload (RUN.EVAL).
|
|
12724
12743
|
*/
|
|
12725
|
-
function cause(env, ctx, kind, payload, place) {
|
|
12744
|
+
function cause$1(env, ctx, kind, payload, place) {
|
|
12726
12745
|
const effect = recordEffect(env, ctx, kind, payload, place);
|
|
12727
12746
|
if ("ok" in effect) return effect;
|
|
12728
|
-
effect.outcome = answer(env.perform, effect, place);
|
|
12747
|
+
effect.outcome = answer$1(env.perform, effect, place);
|
|
12729
12748
|
return effect.outcome;
|
|
12730
12749
|
}
|
|
12731
12750
|
/**
|
|
@@ -12736,8 +12755,8 @@ function causeFromEvaluator(env, ctx, kind, payload, place) {
|
|
|
12736
12755
|
const text = typeof kind === "string" ? kind : kind.join(".");
|
|
12737
12756
|
if (env.running) return fail("#CALC!", `The effect ${text} needs a runner: in a run, the host does each effect.`, { place });
|
|
12738
12757
|
const clause = clauseAt(env, ctx, kind, place);
|
|
12739
|
-
if (clause !== void 0) return "ok" in clause ? clause : drive$
|
|
12740
|
-
return cause(env, ctx, kind, payload, place);
|
|
12758
|
+
if (clause !== void 0) return "ok" in clause ? clause : drive$2(clause.answer(payload), place, text);
|
|
12759
|
+
return cause$1(env, ctx, kind, payload, place);
|
|
12741
12760
|
}
|
|
12742
12761
|
/**
|
|
12743
12762
|
* This function causes the effect of a runner. In an evaluation, the mock answers it at once. In a run, the host does
|
|
@@ -12747,7 +12766,7 @@ function causeFromEvaluator(env, ctx, kind, payload, place) {
|
|
|
12747
12766
|
function* causeAndWait(env, ctx, kind, payload, place) {
|
|
12748
12767
|
const clause = clauseAt(env, ctx, kind, place);
|
|
12749
12768
|
if (clause !== void 0) return "ok" in clause ? clause : yield* clause.answer(payload);
|
|
12750
|
-
if (!env.running) return cause(env, ctx, kind, payload, place);
|
|
12769
|
+
if (!env.running) return cause$1(env, ctx, kind, payload, place);
|
|
12751
12770
|
const effect = recordEffect(env, ctx, kind, payload, place);
|
|
12752
12771
|
if ("ok" in effect) return effect;
|
|
12753
12772
|
const perform = env.perform;
|
|
@@ -12804,7 +12823,7 @@ function hostError(effect, place, error) {
|
|
|
12804
12823
|
* This function gives the answer of the mock to an effect. A throw gives `#CALC!` with the cause, and a `Failure`
|
|
12805
12824
|
* gives its own error value. A promise gives `#CALC!`, because an evaluation does not wait.
|
|
12806
12825
|
*/
|
|
12807
|
-
function answer(perform, effect, place) {
|
|
12826
|
+
function answer$1(perform, effect, place) {
|
|
12808
12827
|
if (perform === void 0) return ok(effect.payload);
|
|
12809
12828
|
let given;
|
|
12810
12829
|
try {
|
|
@@ -12827,10 +12846,10 @@ function evaluateSeen(env, seen, at) {
|
|
|
12827
12846
|
const { place } = at;
|
|
12828
12847
|
if ("gap" in chosen) return fail("#NOEVAL", chosen.gap, { place });
|
|
12829
12848
|
if ("runner" in chosen) {
|
|
12830
|
-
if (!env.running) return drive$
|
|
12849
|
+
if (!env.running) return drive$2(runSeen(env, seen, at, chosen.runner), place, seen.kindText);
|
|
12831
12850
|
env.held += 1;
|
|
12832
12851
|
try {
|
|
12833
|
-
return drive$
|
|
12852
|
+
return drive$2(runSeen(env, seen, at, chosen.runner), place, seen.kindText);
|
|
12834
12853
|
} finally {
|
|
12835
12854
|
env.held -= 1;
|
|
12836
12855
|
}
|
|
@@ -12857,7 +12876,7 @@ function* runSeen(env, seen, at, runner) {
|
|
|
12857
12876
|
}
|
|
12858
12877
|
}
|
|
12859
12878
|
/** This function drives steps that cannot wait. A step that waits gives `#CALC!` at the document (RUN.WAIT). */
|
|
12860
|
-
function drive$
|
|
12879
|
+
function drive$2(steps, place, kindText) {
|
|
12861
12880
|
const step = steps.next();
|
|
12862
12881
|
if (step.done === true) return step.value;
|
|
12863
12882
|
step.value.catch(() => void 0);
|
|
@@ -13569,7 +13588,7 @@ function jsonOfNode(node, self, open) {
|
|
|
13569
13588
|
if (!result.ok) return result;
|
|
13570
13589
|
const value = plainValue(result.value, [...open, self]);
|
|
13571
13590
|
if (!value.ok) return value;
|
|
13572
|
-
setField$
|
|
13591
|
+
setField$2(record, part.key, value.value);
|
|
13573
13592
|
}
|
|
13574
13593
|
return ok(record);
|
|
13575
13594
|
}
|
|
@@ -13595,7 +13614,7 @@ function plainValue(value, open) {
|
|
|
13595
13614
|
for (const key of Object.keys(value)) {
|
|
13596
13615
|
const plain = plainValue(value[key], [...open, value]);
|
|
13597
13616
|
if (!plain.ok) return plain;
|
|
13598
|
-
setField$
|
|
13617
|
+
setField$2(copy, key, plain.value);
|
|
13599
13618
|
}
|
|
13600
13619
|
return ok(copy);
|
|
13601
13620
|
}
|
|
@@ -13673,9 +13692,9 @@ const STD_DEFINITIONS = { evaluators: {
|
|
|
13673
13692
|
"tree.node": treeDefinition,
|
|
13674
13693
|
"ref.resolve": refDefinition
|
|
13675
13694
|
} };
|
|
13676
|
-
const CLOSURE$
|
|
13695
|
+
const CLOSURE$2 = /* @__PURE__ */ Symbol.for("coeval.closure");
|
|
13677
13696
|
/** This function sets an own field, also the field `__proto__` (SHAPE.PROTO). */
|
|
13678
|
-
function setField$
|
|
13697
|
+
function setField$2(target, key, value) {
|
|
13679
13698
|
Object.defineProperty(target, key, {
|
|
13680
13699
|
value,
|
|
13681
13700
|
enumerable: true,
|
|
@@ -13683,10 +13702,10 @@ function setField$1(target, key, value) {
|
|
|
13683
13702
|
configurable: true
|
|
13684
13703
|
});
|
|
13685
13704
|
}
|
|
13686
|
-
function partNamed(parts, key) {
|
|
13705
|
+
function partNamed$1(parts, key) {
|
|
13687
13706
|
return parts.find((part) => part.path.length === 1 && part.path[0] === key);
|
|
13688
13707
|
}
|
|
13689
|
-
function partsUnder(parts, key) {
|
|
13708
|
+
function partsUnder$1(parts, key) {
|
|
13690
13709
|
return parts.filter((part) => part.path.length === 2 && part.path[0] === key);
|
|
13691
13710
|
}
|
|
13692
13711
|
/**
|
|
@@ -13699,7 +13718,7 @@ function partsUnder(parts, key) {
|
|
|
13699
13718
|
*/
|
|
13700
13719
|
function formulaDefinitions(profile = {}) {
|
|
13701
13720
|
const truthy = profile.truthy ?? ((value) => typeof value === "boolean" ? value : void 0);
|
|
13702
|
-
const opOf = (name) => typeof profile.ops === "function" ? profile.ops(name) : own$
|
|
13721
|
+
const opOf = (name) => typeof profile.ops === "function" ? profile.ops(name) : own$2(profile.ops, name);
|
|
13703
13722
|
const noTruth = (what) => fail("#VALUE!", `The ${what} must give a truth value.`);
|
|
13704
13723
|
/** FORMULA.LIST, FORMULA.OPS and FORMULA.COMBINE: the values of parts in order, or the error. */
|
|
13705
13724
|
const valuesOf = (parts, skip) => {
|
|
@@ -13729,7 +13748,7 @@ function formulaDefinitions(profile = {}) {
|
|
|
13729
13748
|
steps = fill(all.values);
|
|
13730
13749
|
}
|
|
13731
13750
|
const head = path[0] === "names" && typeof path[1] === "string" ? path[1] : void 0;
|
|
13732
|
-
const bound = head === void 0 ? void 0 : own$
|
|
13751
|
+
const bound = head === void 0 ? void 0 : own$2(context.names, head);
|
|
13733
13752
|
if (bound instanceof Held) {
|
|
13734
13753
|
walk(["names", head]);
|
|
13735
13754
|
return {
|
|
@@ -13762,7 +13781,7 @@ function formulaDefinitions(profile = {}) {
|
|
|
13762
13781
|
const out = {};
|
|
13763
13782
|
parts.forEach((part, index) => {
|
|
13764
13783
|
const value = all.values[index];
|
|
13765
|
-
if (value !== SKIP) setField$
|
|
13784
|
+
if (value !== SKIP) setField$2(out, String(part.path[0]), value);
|
|
13766
13785
|
});
|
|
13767
13786
|
return ok(out);
|
|
13768
13787
|
};
|
|
@@ -13772,12 +13791,12 @@ function formulaDefinitions(profile = {}) {
|
|
|
13772
13791
|
};
|
|
13773
13792
|
const letIn = ({ parts, context }) => {
|
|
13774
13793
|
const names = {};
|
|
13775
|
-
for (const key of Object.keys(context.names)) setField$
|
|
13776
|
-
for (const binding of partsUnder(parts, "bind")) {
|
|
13794
|
+
for (const key of Object.keys(context.names)) setField$2(names, key, context.names[key]);
|
|
13795
|
+
for (const binding of partsUnder$1(parts, "bind")) {
|
|
13777
13796
|
const result = binding.evaluate();
|
|
13778
|
-
setField$
|
|
13797
|
+
setField$2(names, String(binding.path[1]), result.ok ? result.value : new Held(result.error));
|
|
13779
13798
|
}
|
|
13780
|
-
return partNamed(parts, "body").evaluate({
|
|
13799
|
+
return partNamed$1(parts, "body").evaluate({
|
|
13781
13800
|
...context,
|
|
13782
13801
|
names
|
|
13783
13802
|
});
|
|
@@ -13786,7 +13805,7 @@ function formulaDefinitions(profile = {}) {
|
|
|
13786
13805
|
const params = isRecord(data) ? data["params"] : void 0;
|
|
13787
13806
|
if (!Array.isArray(params) || !params.every((param) => typeof param === "string") || new Set(params).size !== params.length) return fail("#VALUE!", "The params of fn are a list of different texts.");
|
|
13788
13807
|
const names = params;
|
|
13789
|
-
const body = partNamed(parts, "body");
|
|
13808
|
+
const body = partNamed$1(parts, "body");
|
|
13790
13809
|
const clock = activeEnvs[activeEnvs.length - 1] ?? {
|
|
13791
13810
|
applying: 0,
|
|
13792
13811
|
maxDepth: 1e3
|
|
@@ -13797,8 +13816,8 @@ function formulaDefinitions(profile = {}) {
|
|
|
13797
13816
|
clock.applying += 1;
|
|
13798
13817
|
try {
|
|
13799
13818
|
const scope = {};
|
|
13800
|
-
for (const key of Object.keys(context.names)) setField$
|
|
13801
|
-
names.forEach((name, index) => setField$
|
|
13819
|
+
for (const key of Object.keys(context.names)) setField$2(scope, key, context.names[key]);
|
|
13820
|
+
names.forEach((name, index) => setField$2(scope, name, args[index]));
|
|
13802
13821
|
const result = body.evaluate({
|
|
13803
13822
|
...context,
|
|
13804
13823
|
names: scope
|
|
@@ -13809,14 +13828,14 @@ function formulaDefinitions(profile = {}) {
|
|
|
13809
13828
|
clock.applying -= 1;
|
|
13810
13829
|
}
|
|
13811
13830
|
};
|
|
13812
|
-
Object.defineProperty(closure, CLOSURE$
|
|
13831
|
+
Object.defineProperty(closure, CLOSURE$2, { value: { params: names } });
|
|
13813
13832
|
return ok(closure);
|
|
13814
13833
|
};
|
|
13815
13834
|
const call = ({ parts }) => {
|
|
13816
|
-
const target = partNamed(parts, "fn").evaluate();
|
|
13835
|
+
const target = partNamed$1(parts, "fn").evaluate();
|
|
13817
13836
|
if (!target.ok) return target;
|
|
13818
13837
|
if (typeof target.value !== "function") return fail("#VALUE!", "The fn of call must give a function.");
|
|
13819
|
-
const all = valuesOfStrict(partsUnder(parts, "args"));
|
|
13838
|
+
const all = valuesOfStrict(partsUnder$1(parts, "args"));
|
|
13820
13839
|
if (!("values" in all)) return all;
|
|
13821
13840
|
try {
|
|
13822
13841
|
return ok(target.value(...all.values));
|
|
@@ -13825,12 +13844,12 @@ function formulaDefinitions(profile = {}) {
|
|
|
13825
13844
|
}
|
|
13826
13845
|
};
|
|
13827
13846
|
const choice = ({ parts }) => {
|
|
13828
|
-
const test = partNamed(parts, "test").evaluate();
|
|
13847
|
+
const test = partNamed$1(parts, "test").evaluate();
|
|
13829
13848
|
if (!test.ok) return test;
|
|
13830
13849
|
const truth = truthy(test.value);
|
|
13831
13850
|
if (truth === void 0) return noTruth("test of if");
|
|
13832
|
-
if (truth) return partNamed(parts, "then").evaluate();
|
|
13833
|
-
const other = partNamed(parts, "else");
|
|
13851
|
+
if (truth) return partNamed$1(parts, "then").evaluate();
|
|
13852
|
+
const other = partNamed$1(parts, "else");
|
|
13834
13853
|
if (other !== void 0) return other.evaluate();
|
|
13835
13854
|
return ok(Object.hasOwn(profile, "otherwise") ? profile.otherwise : null);
|
|
13836
13855
|
};
|
|
@@ -13848,7 +13867,7 @@ function formulaDefinitions(profile = {}) {
|
|
|
13848
13867
|
};
|
|
13849
13868
|
const op = ({ typePath, parts }) => {
|
|
13850
13869
|
const name = typePath.slice(1).join(".");
|
|
13851
|
-
const lazy = own$
|
|
13870
|
+
const lazy = own$2(profile.lazy, name);
|
|
13852
13871
|
if (lazy !== void 0) try {
|
|
13853
13872
|
return lazy(parts.map((part) => () => part.evaluate()));
|
|
13854
13873
|
} catch (error) {
|
|
@@ -13867,7 +13886,7 @@ function formulaDefinitions(profile = {}) {
|
|
|
13867
13886
|
};
|
|
13868
13887
|
const ext = ({ typePath, doc, context, machine }) => {
|
|
13869
13888
|
const name = typePath.slice(1).join(".");
|
|
13870
|
-
const handler = own$
|
|
13889
|
+
const handler = own$2(profile.ext, name) ?? own$2(STD_EXT, name);
|
|
13871
13890
|
if (handler === void 0) return fail("#NAME?", `The language has no extension ${name}.`);
|
|
13872
13891
|
try {
|
|
13873
13892
|
return handler(doc.value, context, machine?.domains);
|
|
@@ -13903,6 +13922,1124 @@ function valuesOfStrict(parts) {
|
|
|
13903
13922
|
}
|
|
13904
13923
|
return { values };
|
|
13905
13924
|
}
|
|
13925
|
+
// src/stepper.ts
|
|
13926
|
+
const CLOSURE_MARK = "coeval.closure";
|
|
13927
|
+
const HELD_MARK = "coeval.held";
|
|
13928
|
+
const CLOSURE$1 = /* @__PURE__ */ Symbol.for("coeval.closure");
|
|
13929
|
+
const MAX_ALIASES = 32;
|
|
13930
|
+
const MAX_COLLAPSE = 64;
|
|
13931
|
+
const ROOTS$1 = /* @__PURE__ */ Object.freeze([
|
|
13932
|
+
"self",
|
|
13933
|
+
"names",
|
|
13934
|
+
"world",
|
|
13935
|
+
"event",
|
|
13936
|
+
"caps"
|
|
13937
|
+
]);
|
|
13938
|
+
const NO_KEYS$1 = /* @__PURE__ */ Object.freeze([]);
|
|
13939
|
+
function own$1(table, name) {
|
|
13940
|
+
return table !== void 0 && Object.hasOwn(table, name) ? table[name] : void 0;
|
|
13941
|
+
}
|
|
13942
|
+
function setField$1(target, key, value) {
|
|
13943
|
+
Object.defineProperty(target, key, {
|
|
13944
|
+
value,
|
|
13945
|
+
enumerable: true,
|
|
13946
|
+
writable: true,
|
|
13947
|
+
configurable: true
|
|
13948
|
+
});
|
|
13949
|
+
}
|
|
13950
|
+
function closureOf(value) {
|
|
13951
|
+
return isRecord(value) && Object.hasOwn(value, CLOSURE_MARK) ? value[CLOSURE_MARK] : void 0;
|
|
13952
|
+
}
|
|
13953
|
+
function heldOf(value) {
|
|
13954
|
+
if (value instanceof Held) return value.error;
|
|
13955
|
+
return isRecord(value) && Object.hasOwn(value, HELD_MARK) ? value[HELD_MARK] : void 0;
|
|
13956
|
+
}
|
|
13957
|
+
/** The judgment 2: K-START and K-COMPUTED. */
|
|
13958
|
+
function keysOf(type) {
|
|
13959
|
+
if (typeof type === "string") return [type];
|
|
13960
|
+
if (Array.isArray(type)) return type;
|
|
13961
|
+
const steps = type.value.slice(1);
|
|
13962
|
+
return steps.every(isKey$1) ? steps : void 0;
|
|
13963
|
+
}
|
|
13964
|
+
/** A key is a text, or a whole number from 0. */
|
|
13965
|
+
function isKey$1(step) {
|
|
13966
|
+
return typeof step === "string" || typeof step === "number" && Number.isInteger(step) && step >= 0;
|
|
13967
|
+
}
|
|
13968
|
+
/** The judgment 2: the lookup of a kind, with the rules K-FALLBACK to K-NOT-A-KIND. */
|
|
13969
|
+
function lookup(world, type) {
|
|
13970
|
+
const start = keysOf(type);
|
|
13971
|
+
if (start === void 0) return void 0;
|
|
13972
|
+
let keys = start;
|
|
13973
|
+
let aliases = 0;
|
|
13974
|
+
for (;;) {
|
|
13975
|
+
let entries = world.kinds;
|
|
13976
|
+
let fallback = world.fallback;
|
|
13977
|
+
let followed = false;
|
|
13978
|
+
if (keys.length === 0) return void 0;
|
|
13979
|
+
for (let index = 0; index < keys.length; index += 1) {
|
|
13980
|
+
const key = String(keys[index]);
|
|
13981
|
+
const entry = own$1(entries, key);
|
|
13982
|
+
if (entry === void 0) return fallback === void 0 ? void 0 : {
|
|
13983
|
+
kind: fallback,
|
|
13984
|
+
path: keys
|
|
13985
|
+
};
|
|
13986
|
+
if (isAlias(entry)) {
|
|
13987
|
+
aliases += 1;
|
|
13988
|
+
const target = entry.value.slice(1);
|
|
13989
|
+
if (aliases > MAX_ALIASES || entry.value[0] !== "world" || !target.every(isKey$1)) return void 0;
|
|
13990
|
+
keys = [...target, ...keys.slice(index + 1)];
|
|
13991
|
+
followed = true;
|
|
13992
|
+
break;
|
|
13993
|
+
}
|
|
13994
|
+
if (index === keys.length - 1) return isKind(entry) ? {
|
|
13995
|
+
kind: entry,
|
|
13996
|
+
path: keys
|
|
13997
|
+
} : void 0;
|
|
13998
|
+
if (!isNamespace(entry)) return void 0;
|
|
13999
|
+
entries = entry.kinds;
|
|
14000
|
+
fallback = entry.fallback;
|
|
14001
|
+
}
|
|
14002
|
+
if (!followed) return void 0;
|
|
14003
|
+
}
|
|
14004
|
+
}
|
|
14005
|
+
/** The result of the ladder for each rung: a name, `null` for L-STOP, or `undefined` for L-NONE. */
|
|
14006
|
+
function ladder(world, entries, kind, known, verb, has) {
|
|
14007
|
+
const mine = isRecord(entries) ? own$1(entries, verb) : void 0;
|
|
14008
|
+
if (mine !== void 0 && has(mine)) return mine;
|
|
14009
|
+
if (!known) return null;
|
|
14010
|
+
const named = own$1(kind?.verbs, verb);
|
|
14011
|
+
if (named !== void 0 && has(named)) return named;
|
|
14012
|
+
const fallback = own$1(world.defaults, verb);
|
|
14013
|
+
return fallback !== void 0 && has(fallback) ? fallback : void 0;
|
|
14014
|
+
}
|
|
14015
|
+
var Bad = class {
|
|
14016
|
+
reason;
|
|
14017
|
+
at;
|
|
14018
|
+
constructor(reason, at) {
|
|
14019
|
+
this.reason = reason;
|
|
14020
|
+
this.at = at;
|
|
14021
|
+
}
|
|
14022
|
+
};
|
|
14023
|
+
/** The result of the walk for a part: the field is absent from the data (SPLIT-FILL). */
|
|
14024
|
+
const PART = /* @__PURE__ */ Symbol("part");
|
|
14025
|
+
function isDataShape(shape) {
|
|
14026
|
+
return shape.shape === "none" || shape.shape === "text" || shape.shape === "number" || shape.shape === "one";
|
|
14027
|
+
}
|
|
14028
|
+
/** SPLIT-DATA: the reason why a value is not a member of a data shape. */
|
|
14029
|
+
function notMember(shape, value) {
|
|
14030
|
+
if (shape.shape === "text") return typeof value === "string" ? void 0 : "The value must be a text.";
|
|
14031
|
+
if (shape.shape === "one") return shape.values.some((item) => docEquals(item, value)) ? void 0 : `The value must be one of ${JSON.stringify(shape.values)}.`;
|
|
14032
|
+
if (typeof value !== "number") return "The value must be a number.";
|
|
14033
|
+
if (shape.whole === true && !Number.isInteger(value)) return "The value must be a whole number.";
|
|
14034
|
+
if (shape.min !== void 0 && !(value >= shape.min)) return `The value must be ${String(shape.min)} or more.`;
|
|
14035
|
+
if (shape.max !== void 0 && !(value <= shape.max)) return `The value must be ${String(shape.max)} or less.`;
|
|
14036
|
+
}
|
|
14037
|
+
function checkKinds(kinds, item, of, path) {
|
|
14038
|
+
const type = isEnvelope(item) ? keysOf(item.type) : of === void 0 ? void 0 : [of];
|
|
14039
|
+
if (type !== void 0 && kinds.some((kind) => kind.length <= type.length && kind.every((key, index) => String(key) === String(type[index])))) return;
|
|
14040
|
+
throw new Bad(`${isEnvelope(item) ? `The kind ${typeName(item.type)} is not permitted here.` : "A value without an envelope is not permitted here."} The permitted kinds are ${kinds.map((kind) => kind.join(".")).join(", ")}.`, path);
|
|
14041
|
+
}
|
|
14042
|
+
/** The judgment 1: the rules SPLIT-NONE to SPLIT-DEEP. The result holds the parts and the data of SPLIT-FILL. */
|
|
14043
|
+
function split(shape, value) {
|
|
14044
|
+
const slots = [];
|
|
14045
|
+
const slot = (item, path, of, address) => {
|
|
14046
|
+
slots.push({
|
|
14047
|
+
path,
|
|
14048
|
+
key: path.join("."),
|
|
14049
|
+
item,
|
|
14050
|
+
...of === void 0 ? {} : { of },
|
|
14051
|
+
...address ? { address: true } : {}
|
|
14052
|
+
});
|
|
14053
|
+
return PART;
|
|
14054
|
+
};
|
|
14055
|
+
const term = (of) => of === void 0 ? { shape: "term" } : {
|
|
14056
|
+
shape: "term",
|
|
14057
|
+
of
|
|
14058
|
+
};
|
|
14059
|
+
const listData = (items) => items.every((item) => item === PART) ? null : items.map((item) => item === PART ? null : item);
|
|
14060
|
+
const deep = (item, path, of) => {
|
|
14061
|
+
if (isEnvelope(item)) return slot(item, path, of, false);
|
|
14062
|
+
const before = slots.length;
|
|
14063
|
+
if (Array.isArray(item)) {
|
|
14064
|
+
const items = item.map((child, index) => deep(child, [...path, index], of));
|
|
14065
|
+
return slots.length === before ? item : listData(items);
|
|
14066
|
+
}
|
|
14067
|
+
if (!isRecord(item)) return item;
|
|
14068
|
+
const out = {};
|
|
14069
|
+
for (const key of Object.keys(item)) {
|
|
14070
|
+
const kept = deep(item[key], [...path, key], of);
|
|
14071
|
+
if (kept !== PART) setField$1(out, key, kept);
|
|
14072
|
+
}
|
|
14073
|
+
return slots.length === before ? item : out;
|
|
14074
|
+
};
|
|
14075
|
+
const walk = (spec, item, path) => {
|
|
14076
|
+
if (spec === void 0 || spec.shape === "none") return item;
|
|
14077
|
+
if (spec.shape === "text" || spec.shape === "number" || spec.shape === "one") {
|
|
14078
|
+
const reason = notMember(spec, item);
|
|
14079
|
+
if (reason !== void 0) throw new Bad(reason, path);
|
|
14080
|
+
return item;
|
|
14081
|
+
}
|
|
14082
|
+
if (spec.shape === "term") {
|
|
14083
|
+
if (spec.kinds !== void 0) checkKinds(spec.kinds, item, spec.of, path);
|
|
14084
|
+
return slot(item, path, spec.of, spec.address === true);
|
|
14085
|
+
}
|
|
14086
|
+
if (spec.shape === "deep") return deep(item, path, spec.of);
|
|
14087
|
+
if (spec.shape === "list") {
|
|
14088
|
+
if (!Array.isArray(item)) throw new Bad("The value must be a list.", path);
|
|
14089
|
+
const list = item;
|
|
14090
|
+
if (spec.distinct === true) {
|
|
14091
|
+
const twice = list.findIndex((child, index) => list.slice(0, index).some((before) => docEquals(before, child)));
|
|
14092
|
+
if (twice !== -1) throw new Bad("The items of the list must be different.", [...path, twice]);
|
|
14093
|
+
}
|
|
14094
|
+
const each = spec.item ?? term(spec.of);
|
|
14095
|
+
const items = list.map((child, index) => walk(each, child, [...path, index]));
|
|
14096
|
+
return isDataShape(each) ? item : listData(items);
|
|
14097
|
+
}
|
|
14098
|
+
if (!isRecord(item)) throw new Bad("The value must be a record.", path);
|
|
14099
|
+
const out = {};
|
|
14100
|
+
const keep = (key, kept) => {
|
|
14101
|
+
if (kept !== PART) setField$1(out, key, kept);
|
|
14102
|
+
};
|
|
14103
|
+
if (spec.shape === "map") {
|
|
14104
|
+
for (const key of Object.keys(item)) keep(key, walk(spec.item ?? term(spec.of), item[key], [...path, key]));
|
|
14105
|
+
return out;
|
|
14106
|
+
}
|
|
14107
|
+
for (const name of spec.required ?? []) if (!Object.hasOwn(item, name)) throw new Bad(`The field ${name} is missing.`, path);
|
|
14108
|
+
for (const key of Object.keys(item)) {
|
|
14109
|
+
const named = Array.isArray(spec.fields) ? spec.fields.includes(key) : Object.hasOwn(spec.fields, key);
|
|
14110
|
+
if (spec.closed === true && !named) throw new Bad(`The field ${key} is not a field of this kind.`, [...path, key]);
|
|
14111
|
+
const fieldShape = !named ? spec.rest : Array.isArray(spec.fields) ? term(spec.of) : spec.fields[key];
|
|
14112
|
+
keep(key, walk(fieldShape, item[key], [...path, key]));
|
|
14113
|
+
}
|
|
14114
|
+
return out;
|
|
14115
|
+
};
|
|
14116
|
+
try {
|
|
14117
|
+
const data = walk(shape, value, []);
|
|
14118
|
+
return {
|
|
14119
|
+
slots,
|
|
14120
|
+
data: data === PART ? null : data
|
|
14121
|
+
};
|
|
14122
|
+
} catch (error) {
|
|
14123
|
+
if (error instanceof Bad) return error;
|
|
14124
|
+
throw error;
|
|
14125
|
+
}
|
|
14126
|
+
}
|
|
14127
|
+
function copyOf(container) {
|
|
14128
|
+
if (Array.isArray(container)) return [...container];
|
|
14129
|
+
const out = {};
|
|
14130
|
+
for (const key of Object.keys(container)) setField$1(out, key, container[key]);
|
|
14131
|
+
return out;
|
|
14132
|
+
}
|
|
14133
|
+
/** SPLIT-FILL: the value with the item `i` at the path of the slot `i`. The containers on the way are new. */
|
|
14134
|
+
function fillIn(value, slots, items) {
|
|
14135
|
+
const first = slots[0];
|
|
14136
|
+
if (first === void 0) return value;
|
|
14137
|
+
if (first.path.length === 0) return items[0];
|
|
14138
|
+
const root = copyOf(value);
|
|
14139
|
+
const fresh = /* @__PURE__ */ new Set([root]);
|
|
14140
|
+
slots.forEach((part, index) => {
|
|
14141
|
+
let here = root;
|
|
14142
|
+
for (let step = 0; step < part.path.length - 1; step += 1) {
|
|
14143
|
+
const key = part.path[step];
|
|
14144
|
+
let next = here[key];
|
|
14145
|
+
if (!fresh.has(next)) {
|
|
14146
|
+
next = copyOf(next);
|
|
14147
|
+
fresh.add(next);
|
|
14148
|
+
setField$1(here, String(key), next);
|
|
14149
|
+
}
|
|
14150
|
+
here = next;
|
|
14151
|
+
}
|
|
14152
|
+
setField$1(here, String(part.path[part.path.length - 1]), items[index]);
|
|
14153
|
+
});
|
|
14154
|
+
return root;
|
|
14155
|
+
}
|
|
14156
|
+
/** H-CONTEXT: the capabilities of a rule list for one part. */
|
|
14157
|
+
function capsOf(rules, path, caps) {
|
|
14158
|
+
let out = caps;
|
|
14159
|
+
for (const rule of rules ?? []) {
|
|
14160
|
+
if (rule.in !== void 0 && !rule.in.some((pattern) => pathMatches(path, pattern))) continue;
|
|
14161
|
+
if (rule.rule === "mask") return [];
|
|
14162
|
+
if (rule.rule === "only") out = intersectCaps(out, rule.caps);
|
|
14163
|
+
}
|
|
14164
|
+
return out;
|
|
14165
|
+
}
|
|
14166
|
+
/** H-CONTEXT: the context of a part. */
|
|
14167
|
+
function contextOf(site, slot, given) {
|
|
14168
|
+
const parent = site.ctx;
|
|
14169
|
+
const narrow = (context) => context.caps.every((cap) => permits(parent.caps, cap)) ? context : {
|
|
14170
|
+
...context,
|
|
14171
|
+
caps: intersectCaps(parent.caps, context.caps)
|
|
14172
|
+
};
|
|
14173
|
+
const base = given === void 0 || given === parent ? parent : narrow(given);
|
|
14174
|
+
const caps = capsOf(site.rules, slot.path, base.caps);
|
|
14175
|
+
return caps === base.caps ? base : {
|
|
14176
|
+
...base,
|
|
14177
|
+
caps
|
|
14178
|
+
};
|
|
14179
|
+
}
|
|
14180
|
+
/** H-PLACE: the place of the document on top of the stack. */
|
|
14181
|
+
function placeOf$1(stack) {
|
|
14182
|
+
const pieces = [];
|
|
14183
|
+
let base = NO_KEYS$1;
|
|
14184
|
+
for (let index = stack.length - 1; index >= 0; index -= 1) {
|
|
14185
|
+
const frame = stack[index];
|
|
14186
|
+
if (frame.f === "base" || frame.f === "return") {
|
|
14187
|
+
base = frame.place;
|
|
14188
|
+
break;
|
|
14189
|
+
}
|
|
14190
|
+
pieces.push(frame.at);
|
|
14191
|
+
}
|
|
14192
|
+
const out = [...base];
|
|
14193
|
+
for (let index = pieces.length - 1; index >= 0; index -= 1) out.push(...pieces[index]);
|
|
14194
|
+
return out;
|
|
14195
|
+
}
|
|
14196
|
+
function back(c, result) {
|
|
14197
|
+
return {
|
|
14198
|
+
mode: "resume",
|
|
14199
|
+
result: result.ok || result.error.place !== void 0 ? result : placed(result, placeOf$1(c.stack)),
|
|
14200
|
+
stack: c.stack,
|
|
14201
|
+
applying: c.applying,
|
|
14202
|
+
marked: c.marked
|
|
14203
|
+
};
|
|
14204
|
+
}
|
|
14205
|
+
function pushed(c, frame) {
|
|
14206
|
+
c.stack.push(frame);
|
|
14207
|
+
}
|
|
14208
|
+
function popped(c) {
|
|
14209
|
+
c.stack.pop();
|
|
14210
|
+
}
|
|
14211
|
+
/** H-SEAL: the evaluation of a part, with the frame that waits for it on top of the stack. */
|
|
14212
|
+
function enter(c, frame, site, slot, given, marked = c.marked) {
|
|
14213
|
+
frame.at = slot.path;
|
|
14214
|
+
return {
|
|
14215
|
+
mode: "evaluate",
|
|
14216
|
+
value: slot.item,
|
|
14217
|
+
declared: slot.of,
|
|
14218
|
+
depth: site.depth + 1,
|
|
14219
|
+
address: slot.address === true,
|
|
14220
|
+
ctx: contextOf(site, slot, given),
|
|
14221
|
+
stack: c.stack,
|
|
14222
|
+
applying: c.applying,
|
|
14223
|
+
marked
|
|
14224
|
+
};
|
|
14225
|
+
}
|
|
14226
|
+
function partNamed(slots, key) {
|
|
14227
|
+
return slots.find((slot) => slot.path.length === 1 && slot.path[0] === key);
|
|
14228
|
+
}
|
|
14229
|
+
function partsUnder(slots, key) {
|
|
14230
|
+
return slots.filter((slot) => slot.path.length === 2 && slot.path[0] === key);
|
|
14231
|
+
}
|
|
14232
|
+
function truthOf(p, c, value) {
|
|
14233
|
+
const given = forHost(p, c, value);
|
|
14234
|
+
return p.profile.truthy === void 0 ? typeof given === "boolean" ? given : void 0 : p.profile.truthy(given);
|
|
14235
|
+
}
|
|
14236
|
+
function opOf(p, name) {
|
|
14237
|
+
const { ops } = p.profile;
|
|
14238
|
+
return typeof ops === "function" ? ops(name) : own$1(ops, name);
|
|
14239
|
+
}
|
|
14240
|
+
function startValues(p, c, site, then, slots, strict, more = {}) {
|
|
14241
|
+
const frame = {
|
|
14242
|
+
f: "values",
|
|
14243
|
+
at: NO_KEYS$1,
|
|
14244
|
+
site,
|
|
14245
|
+
then,
|
|
14246
|
+
slots,
|
|
14247
|
+
strict,
|
|
14248
|
+
next: 1,
|
|
14249
|
+
values: [],
|
|
14250
|
+
errors: [],
|
|
14251
|
+
skipped: [],
|
|
14252
|
+
...more
|
|
14253
|
+
};
|
|
14254
|
+
const first = slots[0];
|
|
14255
|
+
if (first === void 0) return finish$1(p, c, frame);
|
|
14256
|
+
pushed(c, frame);
|
|
14257
|
+
return enter(c, frame, site, first);
|
|
14258
|
+
}
|
|
14259
|
+
/** F-REF, after the values of the steps. */
|
|
14260
|
+
function finishRef(p, c, doc, steps, site, address) {
|
|
14261
|
+
const path = doc.value;
|
|
14262
|
+
const head = path[0] === "names" && typeof path[1] === "string" ? path[1] : void 0;
|
|
14263
|
+
const bound = head === void 0 ? void 0 : heldOf(own$1(site.ctx.names, head));
|
|
14264
|
+
if (bound !== void 0) return back(c, {
|
|
14265
|
+
ok: false,
|
|
14266
|
+
error: bound
|
|
14267
|
+
});
|
|
14268
|
+
const found = walkPath(p, site.ctx, steps);
|
|
14269
|
+
if (!found.ok) return back(c, fail(found.code, found.reason));
|
|
14270
|
+
if (address) return back(c, ok(found.thing));
|
|
14271
|
+
const reached = isHostThing(found.thing) ? found.thing.toJson() : found.thing;
|
|
14272
|
+
const held = heldOf(reached);
|
|
14273
|
+
if (held !== void 0) return back(c, {
|
|
14274
|
+
ok: false,
|
|
14275
|
+
error: held
|
|
14276
|
+
});
|
|
14277
|
+
if (p.profile.missing?.(forHost(p, c, reached)) === true) return back(c, fail("#N/A", "The path reaches no value."));
|
|
14278
|
+
return back(c, ok(reached));
|
|
14279
|
+
}
|
|
14280
|
+
/** The work of a construct after the values of its parts. */
|
|
14281
|
+
function finish$1(p, c, frame) {
|
|
14282
|
+
const { values, slots } = frame;
|
|
14283
|
+
switch (frame.then) {
|
|
14284
|
+
case "list": return back(c, ok(values));
|
|
14285
|
+
case "record": {
|
|
14286
|
+
const out = {};
|
|
14287
|
+
slots.forEach((slot, index) => {
|
|
14288
|
+
if (!frame.skipped.includes(index)) setField$1(out, String(slot.path[0]), values[index]);
|
|
14289
|
+
});
|
|
14290
|
+
return back(c, ok(out));
|
|
14291
|
+
}
|
|
14292
|
+
case "op": {
|
|
14293
|
+
const name = frame.name;
|
|
14294
|
+
try {
|
|
14295
|
+
const out = opOf(p, name)(...forHost(p, c, values));
|
|
14296
|
+
return back(c, p.profile.check?.(out, name) ?? ok(out));
|
|
14297
|
+
} catch (error) {
|
|
14298
|
+
return back(c, thrown(error, `the operation ${name}`));
|
|
14299
|
+
}
|
|
14300
|
+
}
|
|
14301
|
+
case "step": {
|
|
14302
|
+
const doc = frame.doc;
|
|
14303
|
+
return back(c, ok(slots.length === 0 ? doc : {
|
|
14304
|
+
...doc,
|
|
14305
|
+
value: fillIn(doc.value, slots, values)
|
|
14306
|
+
}));
|
|
14307
|
+
}
|
|
14308
|
+
case "ref": {
|
|
14309
|
+
const doc = frame.doc;
|
|
14310
|
+
return finishRef(p, c, doc, fillIn(doc.value, slots, values), frame.site, frame.address === true);
|
|
14311
|
+
}
|
|
14312
|
+
case "args": return apply(p, c, frame.target, values);
|
|
14313
|
+
}
|
|
14314
|
+
}
|
|
14315
|
+
/** F-CALL and F-FN: an application of a function. */
|
|
14316
|
+
function apply(p, c, target, args) {
|
|
14317
|
+
const closure = closureOf(target);
|
|
14318
|
+
if (closure === void 0) try {
|
|
14319
|
+
return back(c, ok(target(...forHost(p, c, args))));
|
|
14320
|
+
} catch (error) {
|
|
14321
|
+
return back(c, thrown(error, "the function of call"));
|
|
14322
|
+
}
|
|
14323
|
+
const limit = Math.ceil(p.maxDepth / 4);
|
|
14324
|
+
if (c.applying >= limit) return back(c, fail("#DEPTH!", `The applications of functions nest deeper than ${limit} levels.`));
|
|
14325
|
+
pushed(c, {
|
|
14326
|
+
f: "return",
|
|
14327
|
+
place: closure.place.concat(closure.body.path)
|
|
14328
|
+
});
|
|
14329
|
+
return {
|
|
14330
|
+
...enter(c, { at: NO_KEYS$1 }, closure.site, closure.body, scopeOf(closure, args)),
|
|
14331
|
+
applying: c.applying + 1
|
|
14332
|
+
};
|
|
14333
|
+
}
|
|
14334
|
+
function scopeOf(closure, args) {
|
|
14335
|
+
const { ctx } = closure.site;
|
|
14336
|
+
const scope = {};
|
|
14337
|
+
for (const key of Object.keys(ctx.names)) setField$1(scope, key, ctx.names[key]);
|
|
14338
|
+
closure.params.forEach((name, index) => setField$1(scope, name, args[index]));
|
|
14339
|
+
return {
|
|
14340
|
+
...ctx,
|
|
14341
|
+
names: scope
|
|
14342
|
+
};
|
|
14343
|
+
}
|
|
14344
|
+
/** This function makes the host function of a closure. A host calls it, thus it runs a nested stepper. */
|
|
14345
|
+
function hostClosure(p, value, closure) {
|
|
14346
|
+
const known = p.hosts.get(value);
|
|
14347
|
+
if (known !== void 0) return known;
|
|
14348
|
+
const fn = (...args) => {
|
|
14349
|
+
const limit = Math.ceil(p.maxDepth / 4);
|
|
14350
|
+
if (p.applying >= limit) throw new Failure(fail("#DEPTH!", `The applications of functions nest deeper than ${limit} levels.`).error);
|
|
14351
|
+
p.applying += 1;
|
|
14352
|
+
try {
|
|
14353
|
+
const place = closure.place.concat(closure.body.path);
|
|
14354
|
+
const end = drive$1(p, enter({
|
|
14355
|
+
mode: "resume",
|
|
14356
|
+
result: ok(null),
|
|
14357
|
+
stack: [{
|
|
14358
|
+
f: "base",
|
|
14359
|
+
place
|
|
14360
|
+
}],
|
|
14361
|
+
applying: p.applying,
|
|
14362
|
+
marked: true
|
|
14363
|
+
}, { at: NO_KEYS$1 }, closure.site, closure.body, scopeOf(closure, args)));
|
|
14364
|
+
if (!end.result.ok) throw new Failure(end.result.error);
|
|
14365
|
+
return forHost(p, end, end.result.value);
|
|
14366
|
+
} finally {
|
|
14367
|
+
p.applying -= 1;
|
|
14368
|
+
}
|
|
14369
|
+
};
|
|
14370
|
+
Object.defineProperty(fn, CLOSURE$1, { value: { params: closure.params } });
|
|
14371
|
+
p.hosts.set(value, fn);
|
|
14372
|
+
return fn;
|
|
14373
|
+
}
|
|
14374
|
+
/** This function gives a value to host code: a closure is a function, and a held error is a `Held`. */
|
|
14375
|
+
function forHost(p, c, value) {
|
|
14376
|
+
p.applying = c.applying;
|
|
14377
|
+
return c.marked ? hostValue(p, value) : value;
|
|
14378
|
+
}
|
|
14379
|
+
function hostValue(p, value) {
|
|
14380
|
+
if (Array.isArray(value)) {
|
|
14381
|
+
const items = value.map((item) => hostValue(p, item));
|
|
14382
|
+
return items.some((item, index) => item !== value[index]) ? items : value;
|
|
14383
|
+
}
|
|
14384
|
+
if (!isRecord(value)) return value;
|
|
14385
|
+
const closure = closureOf(value);
|
|
14386
|
+
if (closure !== void 0) return hostClosure(p, value, closure);
|
|
14387
|
+
const held = heldOf(value);
|
|
14388
|
+
if (held !== void 0) return new Held(held);
|
|
14389
|
+
let out;
|
|
14390
|
+
for (const key of Object.keys(value)) {
|
|
14391
|
+
const item = hostValue(p, value[key]);
|
|
14392
|
+
if (item !== value[key]) {
|
|
14393
|
+
out ??= copyOf(value);
|
|
14394
|
+
setField$1(out, key, item);
|
|
14395
|
+
}
|
|
14396
|
+
}
|
|
14397
|
+
return out ?? value;
|
|
14398
|
+
}
|
|
14399
|
+
function hostContext(p, c, ctx) {
|
|
14400
|
+
const names = forHost(p, c, ctx.names);
|
|
14401
|
+
return names === ctx.names ? ctx : {
|
|
14402
|
+
...ctx,
|
|
14403
|
+
names
|
|
14404
|
+
};
|
|
14405
|
+
}
|
|
14406
|
+
/** The judgment 3: the steps of a path, with R-NO-ROOT to C-DONE. A failure holds a code and a reason. */
|
|
14407
|
+
function walkPath(p, ctx, path) {
|
|
14408
|
+
const { machine } = p;
|
|
14409
|
+
const adopt = machine.adopt ?? ((value) => value);
|
|
14410
|
+
const failed = (code, reason) => ({
|
|
14411
|
+
ok: false,
|
|
14412
|
+
code,
|
|
14413
|
+
reason,
|
|
14414
|
+
hops: []
|
|
14415
|
+
});
|
|
14416
|
+
const open = [];
|
|
14417
|
+
let collapses = 0;
|
|
14418
|
+
const collapse = (thing) => {
|
|
14419
|
+
let here = thing;
|
|
14420
|
+
if (machine.plain === true) return {
|
|
14421
|
+
ok: true,
|
|
14422
|
+
thing: here,
|
|
14423
|
+
hops: []
|
|
14424
|
+
};
|
|
14425
|
+
while (isReference(here)) {
|
|
14426
|
+
if (open.includes(here)) return failed("#CYCLE!", "The references form a cycle.");
|
|
14427
|
+
collapses += 1;
|
|
14428
|
+
if (collapses > MAX_COLLAPSE) return failed("#CYCLE!", "The path follows more than 64 references. One resolution follows at most 64.");
|
|
14429
|
+
open.push(here);
|
|
14430
|
+
const inner = walk(here.value);
|
|
14431
|
+
open.pop();
|
|
14432
|
+
if (!inner.ok) return inner;
|
|
14433
|
+
here = adopt(inner.thing);
|
|
14434
|
+
}
|
|
14435
|
+
return {
|
|
14436
|
+
ok: true,
|
|
14437
|
+
thing: here,
|
|
14438
|
+
hops: []
|
|
14439
|
+
};
|
|
14440
|
+
};
|
|
14441
|
+
const walk = (steps) => {
|
|
14442
|
+
const root = steps[0];
|
|
14443
|
+
if (typeof root !== "string" || !ROOTS$1.includes(root)) return failed("#REF!", `A path starts with a root: ${ROOTS$1.join(", ")}.`);
|
|
14444
|
+
if (machine.roots !== void 0 && !machine.roots.includes(root)) return failed("#REF!", `The root ${root} is not open here. The open roots are ${machine.roots.join(", ")}.`);
|
|
14445
|
+
const first = collapse(adopt(ctx[root]));
|
|
14446
|
+
if (!first.ok) return first;
|
|
14447
|
+
let here = first.thing;
|
|
14448
|
+
for (let index = 1; index < steps.length; index += 1) {
|
|
14449
|
+
const step = steps[index];
|
|
14450
|
+
const rest = steps.slice(index);
|
|
14451
|
+
if (isHostThing(here) && here.resolve !== void 0 && rest.every(isKey$1)) {
|
|
14452
|
+
const reached = here.resolve(rest);
|
|
14453
|
+
if (reached === void 0) return failed("#N/A", `The path ${rest.join(".")} reaches nothing.`);
|
|
14454
|
+
return collapse(adopt(reached.thing));
|
|
14455
|
+
}
|
|
14456
|
+
const hop = isKey$1(step) ? keyStep(p, here, step) : void 0;
|
|
14457
|
+
if (isKey$1(step)) {
|
|
14458
|
+
if (hop === void 0) {
|
|
14459
|
+
if (root === "names" && index === 1) return failed("#NAME?", `The context has no name ${String(step)}.`);
|
|
14460
|
+
return failed("#N/A", `The step ${String(step)} reaches nothing.`);
|
|
14461
|
+
}
|
|
14462
|
+
here = adopt(hop.thing);
|
|
14463
|
+
} else {
|
|
14464
|
+
const walker = walkerFor(p, step);
|
|
14465
|
+
if (walker === void 0) return failed("#STEP?", "A step is a key, or a document of a kind with the verb step.");
|
|
14466
|
+
const deref = (thing, key) => {
|
|
14467
|
+
const reached = keyStep(p, thing, key);
|
|
14468
|
+
return reached === void 0 ? void 0 : adopt(reached.thing);
|
|
14469
|
+
};
|
|
14470
|
+
const has = (thing, key) => keyStep(p, thing, key) !== void 0;
|
|
14471
|
+
const result = walker({
|
|
14472
|
+
data: step.value,
|
|
14473
|
+
here,
|
|
14474
|
+
context: ctx,
|
|
14475
|
+
deref,
|
|
14476
|
+
has
|
|
14477
|
+
});
|
|
14478
|
+
if (!result.ok) return failed(result.code ?? "#N/A", result.reason);
|
|
14479
|
+
here = adopt(result.thing);
|
|
14480
|
+
}
|
|
14481
|
+
const next = collapse(here);
|
|
14482
|
+
if (!next.ok) return next;
|
|
14483
|
+
here = next.thing;
|
|
14484
|
+
}
|
|
14485
|
+
return {
|
|
14486
|
+
ok: true,
|
|
14487
|
+
thing: here,
|
|
14488
|
+
hops: []
|
|
14489
|
+
};
|
|
14490
|
+
};
|
|
14491
|
+
return path.length === 0 ? failed("#REF!", "A path has at least one step: its root.") : walk(path);
|
|
14492
|
+
}
|
|
14493
|
+
function isReference(thing) {
|
|
14494
|
+
if (!isEnvelope(thing) || !Array.isArray(thing.value)) return false;
|
|
14495
|
+
const keys = keysOf(thing.type);
|
|
14496
|
+
return keys !== void 0 && keys.length === 1 && keys[0] === "ref";
|
|
14497
|
+
}
|
|
14498
|
+
/** R-WALKER: the code of a step document. */
|
|
14499
|
+
function walkerFor(p, step) {
|
|
14500
|
+
const { walkers, world } = p.machine;
|
|
14501
|
+
if (walkers === void 0 || !isEnvelope(step)) return void 0;
|
|
14502
|
+
const found = lookup(world, step.type);
|
|
14503
|
+
const name = ladder(world, field(step, "own"), found?.kind, found !== void 0, "step", (item) => own$1(walkers, item) !== void 0);
|
|
14504
|
+
return typeof name === "string" ? own$1(walkers, name) : void 0;
|
|
14505
|
+
}
|
|
14506
|
+
/** FIELD: the rule of a step in a value. */
|
|
14507
|
+
function fieldOf(value, key) {
|
|
14508
|
+
if (Array.isArray(value)) {
|
|
14509
|
+
if (key === "length") return { thing: value.length };
|
|
14510
|
+
const index = typeof key === "number" ? key : /^\d+$/.test(key) ? Number(key) : -1;
|
|
14511
|
+
return index >= 0 && index < value.length ? { thing: value[index] } : void 0;
|
|
14512
|
+
}
|
|
14513
|
+
if (typeof value !== "object" || value === null || !Object.hasOwn(value, String(key))) return void 0;
|
|
14514
|
+
return { thing: value[String(key)] };
|
|
14515
|
+
}
|
|
14516
|
+
/** The rules S-HOST to S-FIELD: a step with a key. The result is `undefined` for `miss`. */
|
|
14517
|
+
function keyStep(p, thing, key) {
|
|
14518
|
+
const { machine } = p;
|
|
14519
|
+
if (isHostThing(thing)) {
|
|
14520
|
+
const reached = thing.deref(key);
|
|
14521
|
+
return reached !== void 0 || thing.has?.(key) === true ? { thing: reached } : void 0;
|
|
14522
|
+
}
|
|
14523
|
+
if (machine.plain === true || !isEnvelope(thing)) return fieldOf(thing, key);
|
|
14524
|
+
const { derefs, world } = machine;
|
|
14525
|
+
const found = lookup(world, thing.type);
|
|
14526
|
+
const name = derefs === void 0 ? void 0 : ladder(world, field(thing, "own"), found?.kind, found !== void 0, "deref", (item) => own$1(derefs, item) !== void 0);
|
|
14527
|
+
const code = typeof name === "string" ? own$1(derefs, name) : void 0;
|
|
14528
|
+
if (code === void 0) return fieldOf(thing.value, key);
|
|
14529
|
+
const reached = code(thing, key);
|
|
14530
|
+
return reached !== void 0 || code.has?.(thing, key) === true ? { thing: reached } : void 0;
|
|
14531
|
+
}
|
|
14532
|
+
/** A construct of the formula kit, with its compiled evaluator in the machine. */
|
|
14533
|
+
const CONSTRUCTS$2 = {
|
|
14534
|
+
"formula.lit": true,
|
|
14535
|
+
"formula.ref": true,
|
|
14536
|
+
"formula.step": true,
|
|
14537
|
+
"formula.record": true,
|
|
14538
|
+
"formula.list": true,
|
|
14539
|
+
"formula.let": true,
|
|
14540
|
+
"formula.fn": true,
|
|
14541
|
+
"formula.call": true,
|
|
14542
|
+
"formula.if": true,
|
|
14543
|
+
"formula.and": true,
|
|
14544
|
+
"formula.or": true,
|
|
14545
|
+
"formula.op": true,
|
|
14546
|
+
"formula.ext": true
|
|
14547
|
+
};
|
|
14548
|
+
/** The rules F-LIT to F-EXT: the start of a construct. */
|
|
14549
|
+
function construct(p, c, name, doc, keys, slots, site) {
|
|
14550
|
+
const { profile, machine } = p;
|
|
14551
|
+
switch (name) {
|
|
14552
|
+
case "formula.lit": return back(c, ok(doc.value));
|
|
14553
|
+
case "formula.ref": {
|
|
14554
|
+
const path = doc.value;
|
|
14555
|
+
if (!Array.isArray(path) || path.length === 0) return back(c, fail("#VALUE!", "The value of ref is a path: a list that starts with a root, for example [\"names\", \"a\"]."));
|
|
14556
|
+
if (slots.length === 0) return finishRef(p, c, doc, path, site, c.address);
|
|
14557
|
+
return startValues(p, c, site, "ref", slots, true, {
|
|
14558
|
+
doc,
|
|
14559
|
+
address: c.address
|
|
14560
|
+
});
|
|
14561
|
+
}
|
|
14562
|
+
case "formula.step": return startValues(p, c, site, "step", slots, true, { doc });
|
|
14563
|
+
case "formula.record": return startValues(p, c, site, "record", slots, false);
|
|
14564
|
+
case "formula.list": return startValues(p, c, site, "list", slots, false);
|
|
14565
|
+
case "formula.let": {
|
|
14566
|
+
const bindings = partsUnder(slots, "bind");
|
|
14567
|
+
const body = partNamed(slots, "body");
|
|
14568
|
+
const names = {};
|
|
14569
|
+
for (const key of Object.keys(site.ctx.names)) setField$1(names, key, site.ctx.names[key]);
|
|
14570
|
+
const first = bindings[0];
|
|
14571
|
+
if (first === void 0) {
|
|
14572
|
+
const tail = {
|
|
14573
|
+
f: "tail",
|
|
14574
|
+
at: NO_KEYS$1
|
|
14575
|
+
};
|
|
14576
|
+
pushed(c, tail);
|
|
14577
|
+
return enter(c, tail, site, body, {
|
|
14578
|
+
...site.ctx,
|
|
14579
|
+
names
|
|
14580
|
+
});
|
|
14581
|
+
}
|
|
14582
|
+
const frame = {
|
|
14583
|
+
f: "let",
|
|
14584
|
+
at: NO_KEYS$1,
|
|
14585
|
+
site,
|
|
14586
|
+
slots: bindings,
|
|
14587
|
+
body,
|
|
14588
|
+
next: 1,
|
|
14589
|
+
names
|
|
14590
|
+
};
|
|
14591
|
+
pushed(c, frame);
|
|
14592
|
+
return enter(c, frame, site, first);
|
|
14593
|
+
}
|
|
14594
|
+
case "formula.fn": {
|
|
14595
|
+
const params = isRecord(doc.value) ? doc.value["params"] : void 0;
|
|
14596
|
+
if (!Array.isArray(params) || !params.every((item) => typeof item === "string") || new Set(params).size !== params.length) return back(c, fail("#VALUE!", "The params of fn are a list of different texts."));
|
|
14597
|
+
const closure = {
|
|
14598
|
+
params,
|
|
14599
|
+
body: partNamed(slots, "body"),
|
|
14600
|
+
site,
|
|
14601
|
+
place: placeOf$1(c.stack)
|
|
14602
|
+
};
|
|
14603
|
+
return back({
|
|
14604
|
+
...c,
|
|
14605
|
+
marked: true
|
|
14606
|
+
}, ok({ [CLOSURE_MARK]: closure }));
|
|
14607
|
+
}
|
|
14608
|
+
case "formula.call": {
|
|
14609
|
+
const frame = {
|
|
14610
|
+
f: "call",
|
|
14611
|
+
at: NO_KEYS$1,
|
|
14612
|
+
site,
|
|
14613
|
+
args: partsUnder(slots, "args")
|
|
14614
|
+
};
|
|
14615
|
+
pushed(c, frame);
|
|
14616
|
+
return enter(c, frame, site, partNamed(slots, "fn"));
|
|
14617
|
+
}
|
|
14618
|
+
case "formula.if": {
|
|
14619
|
+
const no = partNamed(slots, "else");
|
|
14620
|
+
const frame = {
|
|
14621
|
+
f: "if",
|
|
14622
|
+
at: NO_KEYS$1,
|
|
14623
|
+
site,
|
|
14624
|
+
yes: partNamed(slots, "then"),
|
|
14625
|
+
...no === void 0 ? {} : { no }
|
|
14626
|
+
};
|
|
14627
|
+
pushed(c, frame);
|
|
14628
|
+
return enter(c, frame, site, partNamed(slots, "test"));
|
|
14629
|
+
}
|
|
14630
|
+
case "formula.and":
|
|
14631
|
+
case "formula.or": {
|
|
14632
|
+
const stop = name === "formula.or";
|
|
14633
|
+
const first = slots[0];
|
|
14634
|
+
if (first === void 0) return back(c, ok(!stop));
|
|
14635
|
+
const frame = {
|
|
14636
|
+
f: "logic",
|
|
14637
|
+
at: NO_KEYS$1,
|
|
14638
|
+
site,
|
|
14639
|
+
stop,
|
|
14640
|
+
what: stop ? "term of or" : "term of and",
|
|
14641
|
+
slots,
|
|
14642
|
+
next: 1
|
|
14643
|
+
};
|
|
14644
|
+
pushed(c, frame);
|
|
14645
|
+
return enter(c, frame, site, first);
|
|
14646
|
+
}
|
|
14647
|
+
case "formula.op": {
|
|
14648
|
+
const op = keys.slice(1).join(".");
|
|
14649
|
+
const lazy = own$1(profile.lazy, op);
|
|
14650
|
+
if (lazy !== void 0) {
|
|
14651
|
+
p.applying = c.applying;
|
|
14652
|
+
try {
|
|
14653
|
+
return back(c, lazy(slots.map((slot) => () => nested(p, c, site, slot))));
|
|
14654
|
+
} catch (error) {
|
|
14655
|
+
return back(c, thrown(error, `the operation ${op}`));
|
|
14656
|
+
}
|
|
14657
|
+
}
|
|
14658
|
+
if (opOf(p, op) === void 0) return back(c, fail("#NAME?", `The language has no operation ${op}.`));
|
|
14659
|
+
return startValues(p, c, site, "op", slots, false, { name: op });
|
|
14660
|
+
}
|
|
14661
|
+
default: {
|
|
14662
|
+
const ext = keys.slice(1).join(".");
|
|
14663
|
+
const handler = own$1(profile.ext, ext) ?? own$1(STD_EXT, ext);
|
|
14664
|
+
if (handler === void 0) return back(c, fail("#NAME?", `The language has no extension ${ext}.`));
|
|
14665
|
+
try {
|
|
14666
|
+
return back(c, handler(doc.value, hostContext(p, c, site.ctx), machine.domains));
|
|
14667
|
+
} catch (error) {
|
|
14668
|
+
return back(c, thrown(error, `the extension ${ext}`));
|
|
14669
|
+
}
|
|
14670
|
+
}
|
|
14671
|
+
}
|
|
14672
|
+
}
|
|
14673
|
+
/** H-SEAL for host code: a handle starts a nested stepper, on the stack of the host. */
|
|
14674
|
+
function nested(p, c, site, slot, given) {
|
|
14675
|
+
const stack = [{
|
|
14676
|
+
f: "base",
|
|
14677
|
+
place: placeOf$1(c.stack).concat(slot.path)
|
|
14678
|
+
}];
|
|
14679
|
+
const end = drive$1(p, enter({
|
|
14680
|
+
mode: "resume",
|
|
14681
|
+
result: ok(null),
|
|
14682
|
+
stack,
|
|
14683
|
+
applying: p.applying,
|
|
14684
|
+
marked: c.marked
|
|
14685
|
+
}, { at: NO_KEYS$1 }, site, slot, given));
|
|
14686
|
+
return end.result.ok ? ok(forHost(p, end, end.result.value)) : end.result;
|
|
14687
|
+
}
|
|
14688
|
+
/** RUN.EVAL: an effect of a host evaluator, with RUN.CAP, RUN.ADDRESS and RUN.MOCK. */
|
|
14689
|
+
function cause(p, ctx, kind, payload, place) {
|
|
14690
|
+
const keys = typeof kind === "string" ? kind.split(".") : kind;
|
|
14691
|
+
const text = keys.join(".");
|
|
14692
|
+
const { machine, perform, counts, effects } = p;
|
|
14693
|
+
if (!(machine.permits === void 0 ? permits(ctx.caps, keys) : machine.permits(ctx.caps, keys, ctx))) return fail("#CAP!", `The context has no capability for the effect ${text}.`, { place });
|
|
14694
|
+
const at = placeText(place);
|
|
14695
|
+
const count = counts.get(at) ?? 0;
|
|
14696
|
+
counts.set(at, count + 1);
|
|
14697
|
+
const effect = {
|
|
14698
|
+
index: effects.length,
|
|
14699
|
+
kind: text,
|
|
14700
|
+
path: keys,
|
|
14701
|
+
payload,
|
|
14702
|
+
node: -1,
|
|
14703
|
+
at: 0,
|
|
14704
|
+
place,
|
|
14705
|
+
context: ctx,
|
|
14706
|
+
address: `${at}#${count}`
|
|
14707
|
+
};
|
|
14708
|
+
effects.push(effect);
|
|
14709
|
+
effect.outcome = answer(perform, effect, place);
|
|
14710
|
+
return effect.outcome;
|
|
14711
|
+
}
|
|
14712
|
+
function answer(perform, effect, place) {
|
|
14713
|
+
if (perform === void 0) return ok(effect.payload);
|
|
14714
|
+
let given;
|
|
14715
|
+
try {
|
|
14716
|
+
given = perform(effect);
|
|
14717
|
+
} catch (error) {
|
|
14718
|
+
if (error instanceof Failure) return placed({
|
|
14719
|
+
ok: false,
|
|
14720
|
+
error: error.error
|
|
14721
|
+
}, place);
|
|
14722
|
+
return fail("#CALC!", `The host failed the effect ${effect.kind}: ${describe(error)}`, {
|
|
14723
|
+
place,
|
|
14724
|
+
cause: error
|
|
14725
|
+
});
|
|
14726
|
+
}
|
|
14727
|
+
if (!(given instanceof Promise)) return ok(given);
|
|
14728
|
+
given.catch(() => void 0);
|
|
14729
|
+
return fail("#CALC!", `The mock gave a promise for the effect ${effect.kind}, and an evaluation does not wait.`, { place });
|
|
14730
|
+
}
|
|
14731
|
+
/** E-APPLY for host code: one step of the stepper starts the evaluator. */
|
|
14732
|
+
function hostEvaluator(p, c, name, evaluator, doc, keys, data, slots, site) {
|
|
14733
|
+
const place = placeOf$1(c.stack);
|
|
14734
|
+
const parts = slots.map((slot) => {
|
|
14735
|
+
const header = isEnvelope(slot.item) ? field(slot.item, "name") : void 0;
|
|
14736
|
+
return {
|
|
14737
|
+
key: slot.key,
|
|
14738
|
+
path: slot.path,
|
|
14739
|
+
...typeof header === "string" ? { name: header } : {},
|
|
14740
|
+
evaluate: (given) => nested(p, c, site, slot, given)
|
|
14741
|
+
};
|
|
14742
|
+
});
|
|
14743
|
+
const fill = (items) => fillIn(doc.value, slots, items);
|
|
14744
|
+
p.applying = c.applying;
|
|
14745
|
+
const input = {
|
|
14746
|
+
kind: typeName(doc.type),
|
|
14747
|
+
typePath: keys,
|
|
14748
|
+
doc,
|
|
14749
|
+
value: fill(parts),
|
|
14750
|
+
data,
|
|
14751
|
+
parts,
|
|
14752
|
+
context: hostContext(p, c, site.ctx),
|
|
14753
|
+
place,
|
|
14754
|
+
machine: p.machine,
|
|
14755
|
+
...c.address ? { address: true } : {},
|
|
14756
|
+
resolve: (path, _options) => walkPath(p, site.ctx, path),
|
|
14757
|
+
effect: (kind, payload) => cause(p, site.ctx, kind, payload, place),
|
|
14758
|
+
fill
|
|
14759
|
+
};
|
|
14760
|
+
try {
|
|
14761
|
+
return back(c, evaluator(input));
|
|
14762
|
+
} catch (error) {
|
|
14763
|
+
return back(c, thrown(error, `the evaluator ${name}`));
|
|
14764
|
+
}
|
|
14765
|
+
}
|
|
14766
|
+
/** The judgment 4: the rules E-PART to E-APPLY for one document, in their order. */
|
|
14767
|
+
function evaluateDoc(p, c) {
|
|
14768
|
+
const { value, declared, depth } = c;
|
|
14769
|
+
const { machine, verb } = p;
|
|
14770
|
+
const { world } = machine;
|
|
14771
|
+
const envelope = isEnvelope(value) ? value : void 0;
|
|
14772
|
+
if (envelope === void 0 && declared === void 0) return back(c, fail("#PART?", "The value has no envelope, and its position declares no type."));
|
|
14773
|
+
const doc = envelope ?? {
|
|
14774
|
+
type: declared,
|
|
14775
|
+
value
|
|
14776
|
+
};
|
|
14777
|
+
const found = lookup(world, doc.type);
|
|
14778
|
+
if (depth > p.maxDepth) return back(c, fail("#DEPTH!", `The nesting is deeper than ${p.maxDepth} documents.`));
|
|
14779
|
+
const kindText = typeName(doc.type);
|
|
14780
|
+
const name = ladder(world, envelope === void 0 ? void 0 : field(envelope, "own"), found?.kind, found !== void 0, verb, () => true);
|
|
14781
|
+
if (name === null) return back(c, fail("#KIND?", `The world has no kind ${kindText}.`));
|
|
14782
|
+
const code = typeof name === "string" ? own$1(machine.runners, name) ?? own$1(machine.evaluators, name) : void 0;
|
|
14783
|
+
if (name === void 0 || code === void 0) return back(c, fail("#NOEVAL", `No rung gives an evaluator for ${kindText}.`));
|
|
14784
|
+
const read = split(found?.kind.parts, doc.value);
|
|
14785
|
+
if (read instanceof Bad) {
|
|
14786
|
+
const where = read.at.length === 0 ? "" : ` (at ${read.at.join(".")})`;
|
|
14787
|
+
return back(c, fail("#VALUE!", `${read.reason}${where} The kind is ${kindText}.`));
|
|
14788
|
+
}
|
|
14789
|
+
if (own$1(machine.runners, name) !== void 0) return back(c, fail("#NOEVAL", `The stepper has no runner ${name}.`));
|
|
14790
|
+
const rules = found?.kind.caps;
|
|
14791
|
+
const site = {
|
|
14792
|
+
name,
|
|
14793
|
+
depth,
|
|
14794
|
+
ctx: c.ctx,
|
|
14795
|
+
...rules === void 0 ? {} : { rules }
|
|
14796
|
+
};
|
|
14797
|
+
const keys = found?.path ?? [];
|
|
14798
|
+
if (typeof code === "function") return hostEvaluator(p, c, name, code, doc, keys, read.data, read.slots, site);
|
|
14799
|
+
if (own$1(CONSTRUCTS$2, name) === true) try {
|
|
14800
|
+
return construct(p, c, name, doc, keys, read.slots, site);
|
|
14801
|
+
} catch (error) {
|
|
14802
|
+
return back(c, thrown(error, `the evaluator ${name}`));
|
|
14803
|
+
}
|
|
14804
|
+
const defined = own$1(p.definitions.evaluators, name);
|
|
14805
|
+
if (defined !== void 0) return hostEvaluator(p, c, name, defined, doc, keys, read.data, read.slots, site);
|
|
14806
|
+
return back(c, fail("#NOEVAL", `The stepper has no definition of the compiled evaluator ${name}.`));
|
|
14807
|
+
}
|
|
14808
|
+
/** The next part of a frame with a list of parts. */
|
|
14809
|
+
function nextOf(frame) {
|
|
14810
|
+
const slot = frame.slots[frame.next];
|
|
14811
|
+
if (slot !== void 0) frame.next += 1;
|
|
14812
|
+
return slot;
|
|
14813
|
+
}
|
|
14814
|
+
function resumeValues(p, c, frame) {
|
|
14815
|
+
const { result } = c;
|
|
14816
|
+
const { combine, omit } = p.profile;
|
|
14817
|
+
if (result.ok) frame.values.push(result.value);
|
|
14818
|
+
else if (frame.then === "record" && omit?.(result.error) === true) {
|
|
14819
|
+
frame.skipped.push(frame.values.length);
|
|
14820
|
+
frame.values.push(null);
|
|
14821
|
+
} else if (frame.strict || combine === void 0) {
|
|
14822
|
+
popped(c);
|
|
14823
|
+
return c;
|
|
14824
|
+
} else frame.errors.push(result.error);
|
|
14825
|
+
const slot = nextOf(frame);
|
|
14826
|
+
if (slot !== void 0) return enter(c, frame, frame.site, slot);
|
|
14827
|
+
popped(c);
|
|
14828
|
+
const first = frame.errors[0];
|
|
14829
|
+
if (first === void 0) return finish$1(p, c, frame);
|
|
14830
|
+
return back(c, {
|
|
14831
|
+
ok: false,
|
|
14832
|
+
error: frame.errors.length === 1 ? first : combine(frame.errors)
|
|
14833
|
+
});
|
|
14834
|
+
}
|
|
14835
|
+
/** The rule `resume(k, r)`: the top frame takes a result. An exception of a rule of the profile ends its document. */
|
|
14836
|
+
function resume(p, c) {
|
|
14837
|
+
const stack = c.stack;
|
|
14838
|
+
const frame = stack[stack.length - 1];
|
|
14839
|
+
if (frame === void 0) return {
|
|
14840
|
+
mode: "done",
|
|
14841
|
+
result: c.result,
|
|
14842
|
+
stack,
|
|
14843
|
+
applying: c.applying,
|
|
14844
|
+
marked: c.marked
|
|
14845
|
+
};
|
|
14846
|
+
try {
|
|
14847
|
+
return take(p, c, frame);
|
|
14848
|
+
} catch (error) {
|
|
14849
|
+
if (stack[stack.length - 1] === frame) popped(c);
|
|
14850
|
+
return back(c, thrown(error, `the evaluator ${"site" in frame ? frame.site.name : "of the part"}`));
|
|
14851
|
+
}
|
|
14852
|
+
}
|
|
14853
|
+
function take(p, c, frame) {
|
|
14854
|
+
const stack = c.stack;
|
|
14855
|
+
const { result } = c;
|
|
14856
|
+
switch (frame.f) {
|
|
14857
|
+
case "base":
|
|
14858
|
+
popped(c);
|
|
14859
|
+
return {
|
|
14860
|
+
mode: "done",
|
|
14861
|
+
result,
|
|
14862
|
+
stack,
|
|
14863
|
+
applying: c.applying,
|
|
14864
|
+
marked: c.marked
|
|
14865
|
+
};
|
|
14866
|
+
case "tail":
|
|
14867
|
+
popped(c);
|
|
14868
|
+
return c;
|
|
14869
|
+
case "return":
|
|
14870
|
+
popped(c);
|
|
14871
|
+
return {
|
|
14872
|
+
...c,
|
|
14873
|
+
applying: c.applying - 1
|
|
14874
|
+
};
|
|
14875
|
+
case "values": return resumeValues(p, c, frame);
|
|
14876
|
+
case "let": {
|
|
14877
|
+
const key = String(frame.slots[frame.next - 1].path[1]);
|
|
14878
|
+
setField$1(frame.names, key, result.ok ? result.value : { [HELD_MARK]: result.error });
|
|
14879
|
+
const marked = c.marked || !result.ok;
|
|
14880
|
+
const slot = nextOf(frame);
|
|
14881
|
+
if (slot !== void 0) return enter(c, frame, frame.site, slot, void 0, marked);
|
|
14882
|
+
const tail = {
|
|
14883
|
+
f: "tail",
|
|
14884
|
+
at: NO_KEYS$1
|
|
14885
|
+
};
|
|
14886
|
+
stack[stack.length - 1] = tail;
|
|
14887
|
+
return enter(c, tail, frame.site, frame.body, {
|
|
14888
|
+
...frame.site.ctx,
|
|
14889
|
+
names: frame.names
|
|
14890
|
+
}, marked);
|
|
14891
|
+
}
|
|
14892
|
+
case "call":
|
|
14893
|
+
popped(c);
|
|
14894
|
+
if (!result.ok) return c;
|
|
14895
|
+
if (closureOf(result.value) === void 0 && typeof result.value !== "function") return back(c, fail("#VALUE!", "The fn of call must give a function."));
|
|
14896
|
+
return startValues(p, c, frame.site, "args", frame.args, true, { target: result.value });
|
|
14897
|
+
case "if": {
|
|
14898
|
+
if (!result.ok) {
|
|
14899
|
+
popped(c);
|
|
14900
|
+
return c;
|
|
14901
|
+
}
|
|
14902
|
+
const truth = truthOf(p, c, result.value);
|
|
14903
|
+
if (truth === void 0) {
|
|
14904
|
+
popped(c);
|
|
14905
|
+
return back(c, fail("#VALUE!", "The test of if must give a truth value."));
|
|
14906
|
+
}
|
|
14907
|
+
const branch = truth ? frame.yes : frame.no;
|
|
14908
|
+
if (branch === void 0) {
|
|
14909
|
+
popped(c);
|
|
14910
|
+
return back(c, ok(Object.hasOwn(p.profile, "otherwise") ? p.profile.otherwise : null));
|
|
14911
|
+
}
|
|
14912
|
+
const tail = {
|
|
14913
|
+
f: "tail",
|
|
14914
|
+
at: NO_KEYS$1
|
|
14915
|
+
};
|
|
14916
|
+
stack[stack.length - 1] = tail;
|
|
14917
|
+
return enter(c, tail, frame.site, branch);
|
|
14918
|
+
}
|
|
14919
|
+
case "logic": {
|
|
14920
|
+
if (!result.ok) {
|
|
14921
|
+
popped(c);
|
|
14922
|
+
return c;
|
|
14923
|
+
}
|
|
14924
|
+
const truth = truthOf(p, c, result.value);
|
|
14925
|
+
const value = p.profile.logic === "value";
|
|
14926
|
+
if (truth === void 0) {
|
|
14927
|
+
popped(c);
|
|
14928
|
+
return back(c, fail("#VALUE!", `The ${frame.what} must give a truth value.`));
|
|
14929
|
+
}
|
|
14930
|
+
if (truth === frame.stop) {
|
|
14931
|
+
popped(c);
|
|
14932
|
+
return back(c, value ? result : ok(frame.stop));
|
|
14933
|
+
}
|
|
14934
|
+
const slot = nextOf(frame);
|
|
14935
|
+
if (slot !== void 0) return enter(c, frame, frame.site, slot);
|
|
14936
|
+
popped(c);
|
|
14937
|
+
return back(c, value ? result : ok(!frame.stop));
|
|
14938
|
+
}
|
|
14939
|
+
}
|
|
14940
|
+
}
|
|
14941
|
+
function advance(p, c) {
|
|
14942
|
+
if (c.mode === "evaluate") return evaluateDoc(p, c);
|
|
14943
|
+
return c.mode === "resume" ? resume(p, c) : c;
|
|
14944
|
+
}
|
|
14945
|
+
function drive$1(p, start) {
|
|
14946
|
+
let now = start;
|
|
14947
|
+
while (now.mode !== "done") now = advance(p, now);
|
|
14948
|
+
return now;
|
|
14949
|
+
}
|
|
14950
|
+
function programOf(machine, options) {
|
|
14951
|
+
return {
|
|
14952
|
+
machine,
|
|
14953
|
+
profile: options.profile ?? {},
|
|
14954
|
+
definitions: options.definitions ?? {},
|
|
14955
|
+
verb: options.verb ?? "eval",
|
|
14956
|
+
maxDepth: machine.maxDepth ?? 1e3,
|
|
14957
|
+
hosts: /* @__PURE__ */ new WeakMap(),
|
|
14958
|
+
effects: options.effects ?? [],
|
|
14959
|
+
perform: options.perform,
|
|
14960
|
+
counts: /* @__PURE__ */ new Map(),
|
|
14961
|
+
applying: 0
|
|
14962
|
+
};
|
|
14963
|
+
}
|
|
14964
|
+
/**
|
|
14965
|
+
* This function gives the first configuration of a document: `evaluate(d, Γ, [], [])`.
|
|
14966
|
+
*
|
|
14967
|
+
* @param machine - The world, the evaluators and the other code.
|
|
14968
|
+
* @param doc - The document.
|
|
14969
|
+
* @param context - The names and the capabilities at the root. A context without a world gets the world of the machine.
|
|
14970
|
+
* @param options - The type of a bare root value.
|
|
14971
|
+
* @returns The configuration.
|
|
14972
|
+
*/
|
|
14973
|
+
function stepperStart(machine, doc, context = makeContext(), options = {}) {
|
|
14974
|
+
const ctx = context.world === null ? {
|
|
14975
|
+
...context,
|
|
14976
|
+
world: worldThing(machine.world)
|
|
14977
|
+
} : context;
|
|
14978
|
+
return {
|
|
14979
|
+
mode: "evaluate",
|
|
14980
|
+
value: doc,
|
|
14981
|
+
declared: options.declaredType,
|
|
14982
|
+
depth: 0,
|
|
14983
|
+
address: false,
|
|
14984
|
+
ctx,
|
|
14985
|
+
stack: [],
|
|
14986
|
+
applying: 0,
|
|
14987
|
+
marked: false
|
|
14988
|
+
};
|
|
14989
|
+
}
|
|
14990
|
+
/**
|
|
14991
|
+
* This function does one step. It is pure: the configuration stays as it is, and a host can keep it, store it as JSON and
|
|
14992
|
+
* step it again (STEPPER.DATA). The result of `done` holds a closure as data. The function `stepper` gives a host
|
|
14993
|
+
* function.
|
|
14994
|
+
*
|
|
14995
|
+
* @param machine - The machine of the configuration.
|
|
14996
|
+
* @param configuration - The configuration.
|
|
14997
|
+
* @param options - The profile and the verb of the configuration.
|
|
14998
|
+
* @returns The next configuration, or the same configuration at `done`.
|
|
14999
|
+
*/
|
|
15000
|
+
function stepperNext(machine, configuration, options = {}) {
|
|
15001
|
+
const stack = [...configuration.stack];
|
|
15002
|
+
const top = stack[stack.length - 1];
|
|
15003
|
+
if (top !== void 0) {
|
|
15004
|
+
const { f } = top;
|
|
15005
|
+
if (f === "values") stack[stack.length - 1] = {
|
|
15006
|
+
...top,
|
|
15007
|
+
values: [...top.values],
|
|
15008
|
+
errors: [...top.errors],
|
|
15009
|
+
skipped: [...top.skipped]
|
|
15010
|
+
};
|
|
15011
|
+
else if (f === "let") stack[stack.length - 1] = {
|
|
15012
|
+
...top,
|
|
15013
|
+
names: { ...top.names }
|
|
15014
|
+
};
|
|
15015
|
+
else stack[stack.length - 1] = { ...top };
|
|
15016
|
+
}
|
|
15017
|
+
return advance(programOf(machine, options), {
|
|
15018
|
+
...configuration,
|
|
15019
|
+
stack
|
|
15020
|
+
});
|
|
15021
|
+
}
|
|
15022
|
+
/**
|
|
15023
|
+
* This function evaluates a document with an explicit stack (K95, D158). It gives the result of `reference` for each
|
|
15024
|
+
* document of the kernel and the formula kit (AGREE.STEPPER). The nesting of a document does not use the stack of the
|
|
15025
|
+
* host (STEPPER.DEEP). A host evaluator is opaque: one step starts it, and each of its handles starts a nested
|
|
15026
|
+
* stepper. The stepper does no effects and no runs.
|
|
15027
|
+
*
|
|
15028
|
+
* @param machine - The world, the evaluators and the other code.
|
|
15029
|
+
* @param doc - The document.
|
|
15030
|
+
* @param context - The names and the capabilities at the root.
|
|
15031
|
+
* @param options - The profile of the formula kit, the verb and the type of a bare root value.
|
|
15032
|
+
* @returns The result.
|
|
15033
|
+
*/
|
|
15034
|
+
function stepper(machine, doc, context = makeContext(), options = {}) {
|
|
15035
|
+
const p = programOf(machine, options);
|
|
15036
|
+
try {
|
|
15037
|
+
const end = drive$1(p, stepperStart(machine, doc, context, options));
|
|
15038
|
+
return end.result.ok ? ok(forHost(p, end, end.result.value)) : end.result;
|
|
15039
|
+
} catch (error) {
|
|
15040
|
+
return placed(thrown(error, "the stepper"), []);
|
|
15041
|
+
}
|
|
15042
|
+
}
|
|
13906
15043
|
// src/replay.ts
|
|
13907
15044
|
/**
|
|
13908
15045
|
* This function makes a recorder (RUN.RECORD). The recorder gives each effect to the function `perform` of the host.
|
|
@@ -15132,6 +16269,13 @@ function agree(machine, doc, context = makeContext(), options = {}) {
|
|
|
15132
16269
|
effects: otherEffects,
|
|
15133
16270
|
...options.definitions === void 0 ? {} : { definitions: options.definitions }
|
|
15134
16271
|
});
|
|
16272
|
+
else if (tier === "stepper") other = stepper(machine, doc, context, {
|
|
16273
|
+
...declared,
|
|
16274
|
+
...mock,
|
|
16275
|
+
effects: otherEffects,
|
|
16276
|
+
...options.profile === void 0 ? {} : { profile: options.profile },
|
|
16277
|
+
...options.definitions === void 0 ? {} : { definitions: options.definitions }
|
|
16278
|
+
});
|
|
15135
16279
|
else if (tier === "traced") {
|
|
15136
16280
|
const traced = evaluate(machine, doc, context, {
|
|
15137
16281
|
...declared,
|
|
@@ -15369,7 +16513,7 @@ async function agreeRun(machine, doc, context = makeContext(), options = {}) {
|
|
|
15369
16513
|
let compared;
|
|
15370
16514
|
const replay = replayer(log);
|
|
15371
16515
|
for (const tier of options.tiers ?? DEFAULT_TIERS) {
|
|
15372
|
-
if (tier === "fixed") continue;
|
|
16516
|
+
if (tier === "fixed" || tier === "stepper") continue;
|
|
15373
16517
|
const tierReplay = watched(replay);
|
|
15374
16518
|
const host = { perform: tierReplay.perform };
|
|
15375
16519
|
let other;
|
|
@@ -17488,20 +18632,14 @@ function checkSyntax(profile) {
|
|
|
17488
18632
|
}
|
|
17489
18633
|
// src/generate.ts
|
|
17490
18634
|
/**
|
|
17491
|
-
* This function makes a source of random numbers with a seed
|
|
18635
|
+
* This function makes a source of random numbers with a seed. The numbers come from `mulberry32` of
|
|
18636
|
+
* `@mark1russell7/rigor-generators` (K248, D191). The draws `int`, `chance` and `pick` keep the rules of the core.
|
|
17492
18637
|
*
|
|
17493
18638
|
* @param seed - The seed: a whole number.
|
|
17494
18639
|
* @returns The source.
|
|
17495
18640
|
*/
|
|
17496
18641
|
function random(seed) {
|
|
17497
|
-
|
|
17498
|
-
const next = () => {
|
|
17499
|
-
state = state + 1831565813 >>> 0;
|
|
17500
|
-
let t = state;
|
|
17501
|
-
t = Math.imul(t ^ t >>> 15, t | 1);
|
|
17502
|
-
t ^= t + Math.imul(t ^ t >>> 7, t | 61);
|
|
17503
|
-
return ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
17504
|
-
};
|
|
18642
|
+
const next = mulberry32(seed);
|
|
17505
18643
|
const int = (below) => Math.floor(next() * below);
|
|
17506
18644
|
return {
|
|
17507
18645
|
next,
|
|
@@ -21296,6 +22434,6 @@ function samplesAt(values, closed, depth) {
|
|
|
21296
22434
|
function typeFromSamples(values, options = {}) {
|
|
21297
22435
|
return samplesAt(values, options.closed === true, 0);
|
|
21298
22436
|
}
|
|
21299
|
-
export { ATTRIBUTE_RUNGS, CAPS_TYPE, CIRCULAR_LIMIT, CONSTRUCTS, ENVELOPE_KEYS, Failure, GENERATION_LIMIT, Held, JOURNAL, MAX_SYNTAX_ISSUES, MergeError, PARTS, PART_INFO, ROOTS, RUNGS, STD_CAPS, STD_DEFINITIONS, STD_DOMAINS, STD_EVALUATORS, STD_EXT, STD_MACHINE, STD_RUNNERS, STD_SYNTAX, STD_WALKERS, STD_WORLD, THING, WORLD_SYNTAX, agree, agreeRun, agreeSchedule, agreeTypes, argsKey, ask, atArgsOf, atRuleOf, attributeGraph, attributeTrace, attributeVertexId, boundariesOf, capKeys, check, checkCycles, checkLatent, checkStep, checkSteps, checkSyntax, checkWorld, circularOf, classify, codecLaws, collectOf, compilePath, components, compose, conforms, context, cycles, dataEdges, decodeDomain, decodeLog, decodeValue, defineLanguage, derefStep, describe, docEquals, documentKey, durable, edgesOf, effectEdges, effectsOf, effectsOfVerb, encodeLog, encodeValue, entriesAsJson, equationType, evaluate, extendDomain, factsOf, fail, failures, field, fits, flatten, formulaDefinitions, formulaEvaluators, formulaFacts, formulaKinds, formulaKnown, formulaMachine, fromJson, generate, heights, ifRunner, intersectCaps, isAlias, isAllowedOrder, isClosure, isEnvelope, isHostThing, isKey, isKind, isNamespace, isRecord, isRef, isStackOverflow, isStep, isTypeRef, join, jsTruthy, kindDocument, kindNamed, kindOf, layers, looksLikeKind, lookupKind, makeContext, mapDocs, mapRefs, member, mergeMachines, mergeWorlds, narrow, nearestWalker, necessary, nodeAt, nodeLayers, ok, parse, partCaps, partGrants, partsOf, pathMatches, permits, placeOf, placed, planner, prepare, print, printReads, random, recorder, ref, reference, referenceRun, refsOf, replayer, resolve, resolveCompiled, restrictMachine, restrictWorld, run, sameResult, sameValue, schedule, splitParts, stepLadder, stepOf, stepRank, stored, syntaxFormat, tag, thrown, toJson, treeNodeEvaluator, typeCheck, typeFromSamples, typeFromSchema, typeIssues, typeName, typePath, typeText, typed, typesOf, valueOfThing, verifyReads, walk, worldThing };
|
|
22437
|
+
export { ATTRIBUTE_RUNGS, CAPS_TYPE, CIRCULAR_LIMIT, CONSTRUCTS, ENVELOPE_KEYS, Failure, GENERATION_LIMIT, Held, JOURNAL, MAX_SYNTAX_ISSUES, MergeError, PARTS, PART_INFO, ROOTS, RUNGS, STD_CAPS, STD_DEFINITIONS, STD_DOMAINS, STD_EVALUATORS, STD_EXT, STD_MACHINE, STD_RUNNERS, STD_SYNTAX, STD_WALKERS, STD_WORLD, THING, WORLD_SYNTAX, agree, agreeRun, agreeSchedule, agreeTypes, argsKey, ask, atArgsOf, atRuleOf, attributeGraph, attributeTrace, attributeVertexId, boundariesOf, capKeys, check, checkCycles, checkLatent, checkStep, checkSteps, checkSyntax, checkWorld, circularOf, classify, codecLaws, collectOf, compilePath, components, compose, conforms, context, cycles, dataEdges, decodeDomain, decodeLog, decodeValue, defineLanguage, derefStep, describe, docEquals, documentKey, durable, edgesOf, effectEdges, effectsOf, effectsOfVerb, encodeLog, encodeValue, entriesAsJson, equationType, evaluate, extendDomain, factsOf, fail, failures, field, fits, flatten, formulaDefinitions, formulaEvaluators, formulaFacts, formulaKinds, formulaKnown, formulaMachine, fromJson, generate, heights, ifRunner, intersectCaps, isAlias, isAllowedOrder, isClosure, isEnvelope, isHostThing, isKey, isKind, isNamespace, isRecord, isRef, isStackOverflow, isStep, isTypeRef, join, jsTruthy, kindDocument, kindNamed, kindOf, layers, looksLikeKind, lookupKind, makeContext, mapDocs, mapRefs, member, mergeMachines, mergeWorlds, narrow, nearestWalker, necessary, nodeAt, nodeLayers, ok, parse, partCaps, partGrants, partsOf, pathMatches, permits, placeOf, placed, planner, prepare, print, printReads, random, recorder, ref, reference, referenceRun, refsOf, replayer, resolve, resolveCompiled, restrictMachine, restrictWorld, run, sameResult, sameValue, schedule, splitParts, stepLadder, stepOf, stepRank, stepper, stepperNext, stepperStart, stored, syntaxFormat, tag, thrown, toJson, treeNodeEvaluator, typeCheck, typeFromSamples, typeFromSchema, typeIssues, typeName, typePath, typeText, typed, typesOf, valueOfThing, verifyReads, walk, worldThing };
|
|
21300
22438
|
|
|
21301
22439
|
//# sourceMappingURL=index.js.map
|