@mark1russell7/coeval 0.3.0 → 0.3.2

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/build/index.d.ts CHANGED
@@ -348,10 +348,14 @@ type Alias = {
348
348
  };
349
349
  /** One entry of the world: a kind, a namespace, or an alias. */
350
350
  type WorldEntry = Kind | Namespace | Alias;
351
- /** A world holds the kinds and the defaults that answer the questions. */
351
+ /**
352
+ * A world holds the kinds and the defaults that answer the questions. `fallback` is the kind of each first key that
353
+ * the world does not have. A world with a fallback is open: each path that starts with an unknown key names a kind.
354
+ */
352
355
  interface World {
353
356
  readonly kinds: Readonly<Record<string, WorldEntry>>;
354
357
  readonly defaults: Readonly<Record<string, string>>;
358
+ readonly fallback?: Kind;
355
359
  }
356
360
  /** The result of a lookup of a type in the world. */
357
361
  type Lookup = {
@@ -388,7 +392,8 @@ export declare function isNamespace(entry: WorldEntry | undefined): entry is Nam
388
392
  /**
389
393
  * This function finds the kind that a type names. It walks the path from the root of the world, one key at a
390
394
  * time. An alias on the way is followed until a kind answers (collapse). A cycle of aliases stops the lookup. In a
391
- * namespace with a fallback, a key that the namespace does not have gets the fallback kind.
395
+ * namespace with a fallback, a key that the namespace does not have gets the fallback kind. In an open world, a first
396
+ * key that the world does not have gets the fallback kind of the world.
392
397
  *
393
398
  * @param world - The world.
394
399
  * @param type - The reference to the type.
@@ -904,12 +909,21 @@ interface Runtime {
904
909
  * This function drives several steps at the same time. When one waits, the others go on.
905
910
  *
906
911
  * @param list - One function for each item. Each function starts the steps of its item.
907
- * @param options - The most items that run at the same time. The default is each item.
912
+ * @param options - The most items that run at the same time, and the stop at the first failure.
908
913
  * @returns The steps that give each result, in the order of the list.
909
914
  */
910
- all(list: readonly (() => Steps)[], options?: {
911
- readonly concurrency?: number;
912
- }): Generator<Promise<unknown>, readonly Result[], unknown>;
915
+ all(list: readonly (() => Steps)[], options?: AllOptions): Generator<Promise<unknown>, readonly Result[], unknown>;
916
+ }
917
+ /**
918
+ * The options of a drive of parts at the same time.
919
+ *
920
+ * - `concurrency`: the most parts that run at the same time. The default is each part.
921
+ * - `failFast`: `true` stops at the first part that fails. The parts that did not start do not start, the parts that
922
+ * run stop at their wait, and the results come at once. Each part without a result gives `#ABORT`.
923
+ */
924
+ interface AllOptions {
925
+ readonly concurrency?: number;
926
+ readonly failFast?: boolean;
913
927
  }
914
928
  /** Compiled code: the evaluation of a document in a context. */
915
929
  type Code = (ctx: Context, rt: Runtime) => Result;
@@ -944,6 +958,14 @@ interface CompileInput {
944
958
  /** The keys from the root document to this document. */
945
959
  readonly place: readonly Key[];
946
960
  readonly machine: Machine;
961
+ /**
962
+ * This function gives the value of the document with an item in the place of each part. The containers on the way
963
+ * to a part are new. The data around the parts stays the same objects.
964
+ *
965
+ * @param items - One item for each part, in the order of `parts`, for example the results of the parts.
966
+ * @returns The value with the items.
967
+ */
968
+ fill(items: readonly unknown[]): unknown;
947
969
  }
948
970
  /**
949
971
  * A sealed part. An evaluator can read the binding name of a part and evaluate it. It cannot read the value of the
@@ -998,6 +1020,14 @@ interface EvalInput {
998
1020
  * @returns The payload, or the error `#CAP!`.
999
1021
  */
1000
1022
  effect(kind: Cap, payload: unknown): Result;
1023
+ /**
1024
+ * This function gives the value of the document with an item in the place of each part, for example the result of
1025
+ * each part. The containers on the way to a part are new. The data around the parts stays the same objects.
1026
+ *
1027
+ * @param items - One item for each part, in the order of `parts`.
1028
+ * @returns The value with the items.
1029
+ */
1030
+ fill(items: readonly unknown[]): unknown;
1001
1031
  }
1002
1032
  /** A part for a runner. Its evaluation can wait for the effects in it. */
1003
1033
  interface RunPart {
@@ -1037,15 +1067,22 @@ interface RunInput {
1037
1067
  */
1038
1068
  effect(kind: Cap, payload: unknown): Steps;
1039
1069
  /**
1040
- * This function evaluates parts at the same time. Take the results with `yield*`.
1070
+ * This function evaluates parts at the same time. Take the results with `yield*`. A runner can give its own parts,
1071
+ * for example a part with a different context: each part needs only the function `evaluate`.
1041
1072
  *
1042
1073
  * @param parts - The parts.
1043
- * @param options - The most parts that run at the same time.
1074
+ * @param options - The most parts that run at the same time, and the stop at the first failure.
1044
1075
  * @returns The steps that give each result, in the order of the parts.
1045
1076
  */
1046
- all(parts: readonly RunPart[], options?: {
1047
- readonly concurrency?: number;
1048
- }): Generator<Promise<unknown>, readonly Result[], unknown>;
1077
+ all(parts: readonly RunPart[], options?: AllOptions): Generator<Promise<unknown>, readonly Result[], unknown>;
1078
+ /**
1079
+ * This function gives the value of the document with an item in the place of each part, for example the result of
1080
+ * each part. The containers on the way to a part are new. The data around the parts stays the same objects.
1081
+ *
1082
+ * @param items - One item for each part, in the order of `parts`.
1083
+ * @returns The value with the items.
1084
+ */
1085
+ fill(items: readonly unknown[]): unknown;
1049
1086
  }
1050
1087
  /** An evaluator that is a function of its input. The kernel calls it for each evaluation. */
1051
1088
  type EvalFn = (input: EvalInput) => Result;
@@ -1600,5 +1637,5 @@ export declare function formulaEvaluators(profile?: FormulaProfile): Readonly<Re
1600
1637
  */
1601
1638
  export declare function formulaMachine(profile?: FormulaProfile, more?: Partial<Machine>): Machine;
1602
1639
  //#endregion
1603
- export type { Alias, Answer, AskOptions, Cap, CheckOptions, Classification, Closure, Code, CompileInput, CompiledEvaluator, CompiledPart, CompiledRunner, Construct, Context, Part as ContextPart, DerefCode, DocVisit, Edge, Effect, Envelope, ErrorCode, EvalError, EvalFn, EvalInput, EvalOptions, Evaluator, ExtFn, Failed, FormulaProfile, Give, Header, Hop, HopBy, HostThing, Issue, Json, JsonRecord, KernelCode, Key, Kind, KindSource, LazyOp, Lookup, Machine, NamesSource, Namespace, Navigator, NearestOptions, OpFn, OrderProblem, Outcome, Part$1 as Part, PartInfo, Shape as PartShape, PartSlot, PartsSpec, Perform, Plan, PrepareOptions, RefUse, Resolution, ResolveCode, ResolveOptions, Result, Root, Run, RunCode, RunFn, RunInput, RunOptions, RunPart, Rung, Runner, Runtime, ScopeRule, Shape$1 as Shape, Side, Split, Step, StepSpec, Steps, StopSignal, Stored, Thing, TraceNode, TypeRef, Use, WalkInput, WalkOptions, WalkProblem, WalkResult, Walker, World, WorldEntry };
1640
+ export type { Alias, AllOptions, Answer, AskOptions, Cap, CheckOptions, Classification, Closure, Code, CompileInput, CompiledEvaluator, CompiledPart, CompiledRunner, Construct, Context, Part as ContextPart, DerefCode, DocVisit, Edge, Effect, Envelope, ErrorCode, EvalError, EvalFn, EvalInput, EvalOptions, Evaluator, ExtFn, Failed, FormulaProfile, Give, Header, Hop, HopBy, HostThing, Issue, Json, JsonRecord, KernelCode, Key, Kind, KindSource, LazyOp, Lookup, Machine, NamesSource, Namespace, Navigator, NearestOptions, OpFn, OrderProblem, Outcome, Part$1 as Part, PartInfo, Shape as PartShape, PartSlot, PartsSpec, Perform, Plan, PrepareOptions, RefUse, Resolution, ResolveCode, ResolveOptions, Result, Root, Run, RunCode, RunFn, RunInput, RunOptions, RunPart, Rung, Runner, Runtime, ScopeRule, Shape$1 as Shape, Side, Split, Step, StepSpec, Steps, StopSignal, Stored, Thing, TraceNode, TypeRef, Use, WalkInput, WalkOptions, WalkProblem, WalkResult, Walker, World, WorldEntry };
1604
1641
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":["Shape","Part"],"sources":["../src/doc.ts","../src/errors.ts","../src/world.ts","../src/ladder.ts","../src/deref.ts","../src/classify.ts","../src/parts.ts","../src/evaluate.ts","../src/stdlib.ts","../src/order.ts","../src/context.ts","../src/static.ts","../src/formula.ts"],"mappings":";;KACY,mDAAmD;YAAmC,cAAA;;;KAGtF;YAAuC,cAAA;;;KAGvC;;;;;;;;;;;KAYA,4BAA4B;WAAmB;WAAsB,gBAAgB;;;;;;KAMrF;;WAED,MAAM;;WAEN,OAAO;;WAEP;;WAEA,MAAM,SAAS;;;qBAIb;;;;;;;;wBASG,SAAS,iBAAiB,SAAS;;;;;;;;wBAanC,MAAM,QAAQ,YAAY,cAAc;;;;;;;wBAUxC,MAAM,iBA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AK,OAAO,OAAO,cAAc,QAAQ,OAAO,4BAA4B,UAAS;;UA4DpF;;WAEN,gBAAgB;;WAEhB,aAAa;;WAEb,eAAe;WACf;;WAEA;;;;;;;;;;;;wBAaK,OAAO,OAAO,OAAO,cAAc,UAAS,uBAA4B;;;;;;;;;;;wBA8CxE,QAAQ,OAAO,OAAO,cAAc,SAAS,KAAK,oBAAoB,UAAS;;UAW9E;WACN,MAAM;;WAEN,gBAAgB;WAChB;;;UAIM;;WAEN;;WAEA;;WAEA,gBAAgB;;;;;;;;;;;;;;;;;;;;wBAqBX,MAAM,SAAS,SAAS,cAAc,UAAS,wBAA6B;;;;KClShF,WAAW;;;;;KAMX,UAAU,sBAAsB,cAAc;;KAG9C,SAAS,MAAM,SAAS;;;;;;;;;;;;;;;;UAiBnB;WACN,MAAM,SAAS,eAAe,WAAW,iBAAiB;WAC1D,OAAO,SAAS,eAAe;WAC/B,MAAM,SAAS,eAAe;WAC9B,UAAU;WACV;WACA;WACA,QAAQ,OAAO;WACf,WAAW;WACX,SAAS,gBAAgB,eAAe;;;qBAItC;WACC,OAAgB;EAA5B,YAAY,OAAgB;;cAGxB;;KAGM,eAAe;YAAoD;aAAqB;;;;;;;;;wBAQpF,UAAU,iBAAiB,SAAS;;qBAKvC,SAAS,SAAS,eAAe;;wBAY9B,SAAS;;;;;;;wBA4BT,gBAAgB,SAAS,eAAe;;;;;;;;wBA6CxC,kBAAkB,UAAS,iBAAsB,SAAS,eAAe;;;;;;;;;wBA4PzE,eAAe,UAAS,gBAAqB,OAAM,QAAQ,WAAgB"}
1
+ {"version":3,"file":"index.d.ts","names":["Shape","Part"],"sources":["../src/doc.ts","../src/errors.ts","../src/world.ts","../src/ladder.ts","../src/deref.ts","../src/classify.ts","../src/parts.ts","../src/evaluate.ts","../src/stdlib.ts","../src/order.ts","../src/context.ts","../src/static.ts","../src/formula.ts"],"mappings":";;KACY,mDAAmD;YAAmC,cAAA;;;KAGtF;YAAuC,cAAA;;;KAGvC;;;;;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;;;;;;;;;wBA8PzE,eAAe,UAAS,gBAAqB,OAAM,QAAQ,WAAgB"}
package/build/index.js CHANGED
@@ -70,6 +70,7 @@ function typePath(type) {
70
70
  * @returns The text, for example `git.push`.
71
71
  */
72
72
  function typeName(type) {
73
+ if (typeof type === "string") return type;
73
74
  return typePath(type)?.join(".") ?? "(computed)";
74
75
  }
75
76
  function headerFits(value) {
@@ -88,9 +89,9 @@ function headerFits(value) {
88
89
  * @returns `true` when the value has the form of an envelope.
89
90
  */
90
91
  function isEnvelope(value) {
91
- if (!isRecord(value) || !headerFits(value)) return false;
92
- for (const key in value) if (Object.hasOwn(value, key) && !ENVELOPE_KEYS.includes(key)) return false;
93
- return true;
92
+ if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
93
+ for (const key in value) if (key !== "type" && key !== "value" && key !== "name" && key !== "own" && Object.hasOwn(value, key)) return false;
94
+ return isRecord(value) && headerFits(value);
94
95
  }
95
96
  /**
96
97
  * This function reads a stored document: an envelope that also has the keys of a store, for example `{ _id, type,
@@ -352,7 +353,8 @@ function entryAt(entries, key) {
352
353
  /**
353
354
  * This function finds the kind that a type names. It walks the path from the root of the world, one key at a
354
355
  * time. An alias on the way is followed until a kind answers (collapse). A cycle of aliases stops the lookup. In a
355
- * namespace with a fallback, a key that the namespace does not have gets the fallback kind.
356
+ * namespace with a fallback, a key that the namespace does not have gets the fallback kind. In an open world, a first
357
+ * key that the world does not have gets the fallback kind of the world.
356
358
  *
357
359
  * @param world - The world.
358
360
  * @param type - The reference to the type.
@@ -369,7 +371,7 @@ function lookupKind(world, type) {
369
371
  let aliases = 0;
370
372
  for (;;) {
371
373
  let entries = world.kinds;
372
- let fallback;
374
+ let fallback = world.fallback;
373
375
  let entry;
374
376
  let followed = false;
375
377
  for (let index = 0; index < path.length; index += 1) {
@@ -1017,14 +1019,17 @@ var Bad = class {
1017
1019
  this.at = at;
1018
1020
  }
1019
1021
  };
1022
+ /** This function sets an own data property. Only the key `__proto__` needs `defineProperty`. */
1020
1023
  function setOwn$1(target, key, value) {
1021
- Object.defineProperty(target, key, {
1024
+ if (key === "__proto__") Object.defineProperty(target, key, {
1022
1025
  value,
1023
1026
  enumerable: true,
1024
1027
  writable: true,
1025
1028
  configurable: true
1026
1029
  });
1030
+ else target[key] = value;
1027
1031
  }
1032
+ const NO_SLOTS = Object.freeze([]);
1028
1033
  function hasSlots(template) {
1029
1034
  return template.t !== "data";
1030
1035
  }
@@ -1037,6 +1042,12 @@ function hasSlots(template) {
1037
1042
  * @returns The parts and a way to fill their places, or the reason why the value does not have the shape.
1038
1043
  */
1039
1044
  function splitParts(shape, value) {
1045
+ if (shape === void 0 || shape.shape === "none") return {
1046
+ ok: true,
1047
+ parts: NO_SLOTS,
1048
+ data: value,
1049
+ fill: () => value
1050
+ };
1040
1051
  const parts = [];
1041
1052
  const slot = (item, path, of) => {
1042
1053
  parts.push({
@@ -1331,18 +1342,24 @@ var Session = class {
1331
1342
  *all(list, options = {}) {
1332
1343
  const results = new Array(list.length);
1333
1344
  const limit = Math.max(1, options.concurrency ?? list.length);
1345
+ const failFast = options.failFast === true;
1346
+ let failed = false;
1334
1347
  const active = [];
1335
1348
  let next = 0;
1349
+ const settle = (index, result) => {
1350
+ results[index] = result;
1351
+ if (failFast && !result.ok) failed = true;
1352
+ };
1336
1353
  const advance = (index, steps, input) => {
1337
1354
  let step;
1338
1355
  try {
1339
1356
  step = input.threw ? steps.throw(input.error) : steps.next(input.value);
1340
1357
  } catch (error) {
1341
- results[index] = thrown(error, "a part");
1358
+ settle(index, thrown(error, "a part"));
1342
1359
  return;
1343
1360
  }
1344
1361
  if (step.done === true) {
1345
- results[index] = step.value;
1362
+ settle(index, step.value);
1346
1363
  return;
1347
1364
  }
1348
1365
  const item = {
@@ -1362,7 +1379,7 @@ var Session = class {
1362
1379
  active.push(item);
1363
1380
  };
1364
1381
  const start = () => {
1365
- while (active.length < limit && next < list.length) {
1382
+ while (!failed && active.length < limit && next < list.length) {
1366
1383
  const index = next;
1367
1384
  next += 1;
1368
1385
  const begin = list[index];
@@ -1370,19 +1387,25 @@ var Session = class {
1370
1387
  try {
1371
1388
  steps = begin();
1372
1389
  } catch (error) {
1373
- results[index] = thrown(error, "a part");
1390
+ settle(index, thrown(error, "a part"));
1374
1391
  continue;
1375
1392
  }
1376
1393
  advance(index, steps, { threw: false });
1377
1394
  }
1378
1395
  };
1379
1396
  start();
1380
- while (active.length > 0) {
1397
+ while (active.length > 0 && !failed) {
1381
1398
  const settled = yield Promise.race(active.map((item) => item.pending));
1382
1399
  active.splice(active.indexOf(settled.item), 1);
1383
1400
  advance(settled.item.index, settled.item.steps, settled);
1384
1401
  start();
1385
1402
  }
1403
+ if (!failed) return results;
1404
+ const stopped = fail("#ABORT", "The part stopped: a part before it failed, and the parts run with failFast.");
1405
+ for (const item of active) try {
1406
+ item.steps.return(stopped);
1407
+ } catch {}
1408
+ for (let index = 0; index < list.length; index += 1) if (results[index] === void 0) results[index] = stopped;
1386
1409
  return results;
1387
1410
  }
1388
1411
  enter(meta, ctx) {
@@ -1538,32 +1561,73 @@ function finish(c, meta, code, run) {
1538
1561
  run: tracedRun
1539
1562
  };
1540
1563
  }
1564
+ /**
1565
+ * This function finds the evaluator of the verb `eval` without the record of the rungs, for a compilation without a
1566
+ * trace. It gives the same evaluator as `ask`: the own entry, then the kind, then the default of the world.
1567
+ */
1568
+ function evaluatorOf(world, envelope, found) {
1569
+ const own = envelope?.own;
1570
+ const ownName = own !== void 0 && Object.hasOwn(own, "eval") ? own["eval"] : void 0;
1571
+ if (ownName !== void 0) return {
1572
+ name: ownName,
1573
+ unknown: false
1574
+ };
1575
+ if (!found.ok) return { unknown: true };
1576
+ const verbs = found.kind.verbs;
1577
+ const name = Object.hasOwn(verbs, "eval") ? verbs["eval"] : Object.hasOwn(world.defaults, "eval") ? world.defaults["eval"] : void 0;
1578
+ return name === void 0 ? { unknown: false } : {
1579
+ name,
1580
+ unknown: false
1581
+ };
1582
+ }
1583
+ /** The meta of a node of a compilation without a trace. Only a trace reads the meta of a node. */
1584
+ const NO_META = Object.freeze({
1585
+ path: [],
1586
+ doc: {
1587
+ type: "?",
1588
+ value: null
1589
+ },
1590
+ declared: false,
1591
+ answer: NO_ANSWER,
1592
+ side: "derive"
1593
+ });
1541
1594
  function compileNode(c, value, place, declared, depth) {
1542
1595
  const envelope = isEnvelope(value) ? value : void 0;
1543
1596
  const doc = envelope ?? {
1544
1597
  type: declared ?? "?",
1545
1598
  value
1546
1599
  };
1547
- const meta0 = {
1600
+ const meta0 = c.traced ? {
1548
1601
  path: place.map(String),
1549
1602
  doc,
1550
1603
  declared: envelope === void 0,
1551
1604
  answer: NO_ANSWER,
1552
1605
  side: "derive"
1553
- };
1606
+ } : NO_META;
1554
1607
  if (envelope === void 0 && declared === void 0) return failing(c, meta0, place, "#PART?", "The value has no envelope, and its position declares no type.");
1555
1608
  if (depth > c.maxDepth) return failing(c, meta0, place, "#DEPTH!", `The nesting is deeper than ${c.maxDepth} documents.`);
1556
- const answer = ask(c.machine.world, envelope ?? {}, "eval", declared === void 0 ? {} : { declaredType: declared });
1557
- const found = lookupKind(c.machine.world, doc.type);
1609
+ const world = c.machine.world;
1610
+ const found = lookupKind(world, doc.type);
1558
1611
  const kind = found.ok ? found.kind : void 0;
1559
- const meta = {
1560
- ...meta0,
1561
- answer,
1562
- side: kind?.side ?? "derive"
1563
- };
1612
+ let meta = meta0;
1613
+ let name;
1614
+ let unknown;
1615
+ if (c.traced) {
1616
+ const answer = ask(world, envelope ?? {}, "eval", declared === void 0 ? {} : { declaredType: declared });
1617
+ meta = {
1618
+ ...meta0,
1619
+ answer,
1620
+ side: kind?.side ?? "derive"
1621
+ };
1622
+ name = answer.evaluator;
1623
+ unknown = answer.error === "unknown-kind";
1624
+ } else {
1625
+ const quick = evaluatorOf(world, envelope, found);
1626
+ name = quick.name;
1627
+ unknown = quick.unknown;
1628
+ }
1564
1629
  const kindText = typeName(doc.type);
1565
- if (answer.error === "unknown-kind") return failing(c, meta, place, "#KIND?", `The world has no kind ${kindText}.`);
1566
- const name = answer.evaluator;
1630
+ if (unknown) return failing(c, meta, place, "#KIND?", `The world has no kind ${kindText}.`);
1567
1631
  const runners = c.machine.runners ?? {};
1568
1632
  const runner = name !== void 0 && Object.hasOwn(runners, name) ? runners[name] : void 0;
1569
1633
  const evaluator = name !== void 0 && Object.hasOwn(c.machine.evaluators, name) ? c.machine.evaluators[name] : void 0;
@@ -1574,12 +1638,18 @@ function compileNode(c, value, place, declared, depth) {
1574
1638
  return failing(c, meta, place, "#VALUE!", `${split.reason}${at} The kind is ${kindText}.`);
1575
1639
  }
1576
1640
  const parts = split.parts.map((slot) => {
1577
- const compiled = compileNode(c, slot.item, [...place, ...slot.path], slot.of, depth + 1);
1578
- const header = isEnvelope(slot.item) && isRecord(slot.item) && typeof slot.item["name"] === "string" ? slot.item["name"] : void 0;
1579
- return {
1641
+ const item = slot.item;
1642
+ const compiled = compileNode(c, item, place.concat(slot.path), slot.of, depth + 1);
1643
+ const header = typeof item?.name === "string" && isEnvelope(item) ? item.name : void 0;
1644
+ return header === void 0 ? {
1580
1645
  key: slot.key,
1581
1646
  path: slot.path,
1582
- ...header === void 0 ? {} : { name: header },
1647
+ code: compiled.code,
1648
+ run: compiled.run
1649
+ } : {
1650
+ key: slot.key,
1651
+ path: slot.path,
1652
+ name: header,
1583
1653
  code: compiled.code,
1584
1654
  run: compiled.run
1585
1655
  };
@@ -1592,9 +1662,9 @@ function compileNode(c, value, place, declared, depth) {
1592
1662
  data: split.data,
1593
1663
  parts,
1594
1664
  place,
1595
- machine: c.machine
1665
+ machine: c.machine,
1666
+ fill: (items) => split.parts.length === 0 ? doc.value : split.fill(items)
1596
1667
  };
1597
- const who = `the evaluator ${name}`;
1598
1668
  if (runner !== void 0) {
1599
1669
  const inner = isCompiledRunner(runner) ? runner.compileRun(input) : interpretRun(runner, input, split.fill);
1600
1670
  const run = function* (ctx, rt) {
@@ -1612,7 +1682,7 @@ function compileNode(c, value, place, declared, depth) {
1612
1682
  try {
1613
1683
  return placed(inner(ctx, rt), place);
1614
1684
  } catch (error) {
1615
- return placed(thrown(error, who), place);
1685
+ return placed(thrown(error, `the evaluator ${name}`), place);
1616
1686
  }
1617
1687
  };
1618
1688
  return finish(c, meta, code, function* (ctx, rt) {
@@ -1640,7 +1710,8 @@ function interpret(fn, input, fill) {
1640
1710
  context: ctx,
1641
1711
  place,
1642
1712
  resolve: (path, options) => rt.resolve(ctx, path, options),
1643
- effect: (effectKind, payload) => rt.effect(ctx, effectKind, payload, place)
1713
+ effect: (effectKind, payload) => rt.effect(ctx, effectKind, payload, place),
1714
+ fill: input.fill
1644
1715
  });
1645
1716
  };
1646
1717
  }
@@ -1666,7 +1737,8 @@ function interpretRun(fn, input, fill) {
1666
1737
  place,
1667
1738
  resolve: (path, options) => rt.resolve(ctx, path, options),
1668
1739
  effect: (effectKind, payload) => rt.runEffect(ctx, effectKind, payload, place),
1669
- all: (list, options) => rt.all(list.map((part) => () => part.evaluate()), options)
1740
+ all: (list, options) => rt.all(list.map((part) => () => part.evaluate()), options),
1741
+ fill: input.fill
1670
1742
  });
1671
1743
  };
1672
1744
  }
@@ -1713,8 +1785,8 @@ function prepare(machine, doc, options = {}) {
1713
1785
  machine,
1714
1786
  traced: c.traced,
1715
1787
  root: compiled,
1716
- evaluate(context = makeContext(), evalOptions = {}) {
1717
- const s = new Session(machine, false, c.traced, void 0, void 0, evalOptions.effects);
1788
+ evaluate(context = makeContext(), evalOptions) {
1789
+ const s = new Session(machine, false, c.traced, void 0, void 0, evalOptions?.effects);
1718
1790
  return root.code(rootContext(machine, context), s);
1719
1791
  },
1720
1792
  run(context = makeContext(), runOptions = {}) {
@@ -2711,6 +2783,13 @@ function scopesOf(rules, value, slots) {
2711
2783
  later
2712
2784
  };
2713
2785
  }
2786
+ /** The names of a walk without names. A walk does not change a set at any time: it makes a new set to add names. */
2787
+ const NO_NAMES = /* @__PURE__ */ new Set();
2788
+ /** This function gives the options of a walk without the names of the host. */
2789
+ function withoutNames(options) {
2790
+ const { names: _host, ...rest } = options;
2791
+ return rest;
2792
+ }
2714
2793
  /**
2715
2794
  * This function visits each document of a document: the root and each part at each depth, by the contracts of the
2716
2795
  * kinds. A part of a kind that the world does not have is not visited. The walk uses no stack of the host for the
@@ -2722,14 +2801,15 @@ function scopesOf(rules, value, slots) {
2722
2801
  * @param options - The type of a bare root value, the names of the host, and a function for the problems.
2723
2802
  */
2724
2803
  function walk(world, doc, visit, options = {}) {
2804
+ const names = options.names === void 0 || options.names.length === 0 ? NO_NAMES : new Set(options.names);
2725
2805
  const stack = [{
2726
2806
  value: doc,
2727
2807
  place: [],
2728
2808
  at: [],
2729
2809
  declared: options.declaredType,
2730
2810
  depth: 0,
2731
- names: new Set(options.names ?? []),
2732
- later: /* @__PURE__ */ new Set()
2811
+ names,
2812
+ later: NO_NAMES
2733
2813
  }];
2734
2814
  while (stack.length > 0) {
2735
2815
  const item = stack.pop();
@@ -2749,15 +2829,21 @@ function walk(world, doc, visit, options = {}) {
2749
2829
  };
2750
2830
  const found = lookupKind(world, doc.type);
2751
2831
  const kind = found.ok ? found.kind : void 0;
2752
- if (visit({
2832
+ if (visit(kind === void 0 ? {
2753
2833
  place: item.place,
2754
2834
  at: item.at,
2755
2835
  doc,
2756
2836
  declared: envelope === void 0,
2757
- ...kind === void 0 ? {} : {
2758
- kind,
2759
- typePath: found.ok ? found.path : []
2760
- },
2837
+ depth: item.depth,
2838
+ names: item.names,
2839
+ later: item.later
2840
+ } : {
2841
+ place: item.place,
2842
+ at: item.at,
2843
+ doc,
2844
+ declared: envelope === void 0,
2845
+ kind,
2846
+ typePath: found.ok ? found.path : [],
2761
2847
  depth: item.depth,
2762
2848
  names: item.names,
2763
2849
  later: item.later
@@ -2803,7 +2889,6 @@ function walk(world, doc, visit, options = {}) {
2803
2889
  */
2804
2890
  function refsOf(world, doc, options = {}) {
2805
2891
  const out = [];
2806
- const { names: _host, ...rest } = options;
2807
2892
  walk(world, doc, (v) => {
2808
2893
  if (!isRef(v.doc)) return void 0;
2809
2894
  const path = v.doc.value;
@@ -2818,7 +2903,7 @@ function refsOf(world, doc, options = {}) {
2818
2903
  free: !bound
2819
2904
  });
2820
2905
  return "skip";
2821
- }, rest);
2906
+ }, options.names === void 0 ? options : withoutNames(options));
2822
2907
  return out;
2823
2908
  }
2824
2909
  function setAt(value, path, next) {
@@ -3005,13 +3090,18 @@ function jsTruthy(value) {
3005
3090
  function strictTruthy(value) {
3006
3091
  return typeof value === "boolean" ? value : void 0;
3007
3092
  }
3093
+ /**
3094
+ * This function sets an own data property. Only the key `__proto__` needs `defineProperty`: an assignment to it
3095
+ * changes the prototype. An assignment is faster for each other key of a new plain object.
3096
+ */
3008
3097
  function setOwn(target, key, value) {
3009
- Object.defineProperty(target, key, {
3098
+ if (key === "__proto__") Object.defineProperty(target, key, {
3010
3099
  value,
3011
3100
  enumerable: true,
3012
3101
  writable: true,
3013
3102
  configurable: true
3014
3103
  });
3104
+ else target[key] = value;
3015
3105
  }
3016
3106
  function compiled(compile) {
3017
3107
  return { compile };
@@ -3194,16 +3284,18 @@ function formulaEvaluators(profile = {}) {
3194
3284
  };
3195
3285
  }),
3196
3286
  "formula.record": compiled(({ value }) => {
3197
- const fields = Object.entries(partsOf(value));
3287
+ const fields = partsOf(value);
3288
+ const keys = Object.keys(fields);
3289
+ const codes = keys.map((key) => fields[key].code);
3198
3290
  return (ctx, rt) => {
3199
3291
  const out = {};
3200
- for (const [key, part] of fields) {
3201
- const result = part.code(ctx, rt);
3292
+ for (let index = 0; index < keys.length; index += 1) {
3293
+ const result = codes[index](ctx, rt);
3202
3294
  if (!result.ok) {
3203
3295
  if (omit !== void 0 && omit(result.error)) continue;
3204
3296
  return result;
3205
3297
  }
3206
- setOwn(out, key, result.value);
3298
+ setOwn(out, keys[index], result.value);
3207
3299
  }
3208
3300
  return ok(out);
3209
3301
  };