@mark1russell7/coeval 0.6.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +32 -5
- package/build/index.d.ts +1568 -271
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4779 -492
- package/build/index.js.map +1 -1
- package/package.json +1 -1
- package/src/agree.ts +15 -3
- package/src/conform.ts +1068 -0
- package/src/deref.ts +284 -47
- package/src/durable.ts +238 -0
- package/src/effects.ts +110 -0
- package/src/errors.ts +2 -1
- package/src/evaluate.ts +472 -111
- package/src/facts.ts +252 -0
- package/src/formula.ts +433 -36
- package/src/graph.ts +399 -0
- package/src/index.ts +28 -0
- package/src/ladder.ts +40 -1
- package/src/merge.ts +91 -4
- package/src/parts.ts +26 -11
- package/src/providers.ts +286 -0
- package/src/reads.ts +105 -0
- package/src/reference.ts +19 -7
- package/src/schedule.ts +436 -0
- package/src/static.ts +266 -29
- package/src/stdlib.ts +24 -7
- package/src/types.ts +741 -0
- package/src/typing.ts +390 -0
- package/src/world.ts +63 -9
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/coeval",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "coeval: the kernel of declarative languages. Documents in envelopes, a ladder that finds the evaluator, kind contracts, compiled plans, a static kit, a formula kit and a run side with capabilities.",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./build/index.js",
|
package/src/agree.ts
CHANGED
|
@@ -25,12 +25,20 @@ export interface TierResult {
|
|
|
25
25
|
export interface TierInput {
|
|
26
26
|
/** The mock of the host, when `agree` has one (AGREE.MOCK). The tier answers each effect with it. */
|
|
27
27
|
readonly perform?: Perform;
|
|
28
|
+
/** The verb of `agree`, when its options name one (VERB.AGREE). A tier that does not serve the verb fails. */
|
|
29
|
+
readonly verb?: string;
|
|
28
30
|
}
|
|
29
31
|
|
|
30
32
|
/** The options of `agree`. */
|
|
31
33
|
export interface AgreeOptions {
|
|
32
34
|
/** The type of a bare root value. */
|
|
33
35
|
readonly declaredType?: string;
|
|
36
|
+
/**
|
|
37
|
+
* The verb of each tier, as in `prepare`. The default is `eval`. The plan, the reference, the traced evaluation and a
|
|
38
|
+
* second evaluation each ask the ladder for this verb (VERB.AGREE). The second tier of a language gets it in its
|
|
39
|
+
* input.
|
|
40
|
+
*/
|
|
41
|
+
readonly verb?: string;
|
|
34
42
|
/** The definitional code of the compiled evaluators of the machine, for the reference. */
|
|
35
43
|
readonly definitions?: Definitions;
|
|
36
44
|
/** The tiers to compare with the plan. The default is the reference, the traced evaluation and a second evaluation. */
|
|
@@ -40,7 +48,7 @@ export interface AgreeOptions {
|
|
|
40
48
|
*
|
|
41
49
|
* @param doc - The document.
|
|
42
50
|
* @param context - The context.
|
|
43
|
-
* @param input - The mock of the host, when `agree` has
|
|
51
|
+
* @param input - The mock of the host and the verb, when `agree` has them.
|
|
44
52
|
* @returns The result, or the result with the effects.
|
|
45
53
|
*/
|
|
46
54
|
readonly other?: (doc: unknown, context: Context, input: TierInput) => Result | TierResult;
|
|
@@ -179,8 +187,12 @@ function effectsDiffer(a: readonly Effect[], b: readonly Effect[], options: Agre
|
|
|
179
187
|
* @returns The result of the plan, or the first tier that disagrees and the reason.
|
|
180
188
|
*/
|
|
181
189
|
export function agree(machine: Machine, doc: unknown, context: Context = makeContext(), options: AgreeOptions = {}): Agreement {
|
|
182
|
-
const declared =
|
|
190
|
+
const declared = {
|
|
191
|
+
...(options.declaredType === undefined ? {} : { declaredType: options.declaredType }),
|
|
192
|
+
...(options.verb === undefined ? {} : { verb: options.verb }),
|
|
193
|
+
};
|
|
183
194
|
const mock = options.perform === undefined ? {} : { perform: options.perform };
|
|
195
|
+
const tierInput: TierInput = { ...mock, ...(options.verb === undefined ? {} : { verb: options.verb }) };
|
|
184
196
|
const observe = options.observe;
|
|
185
197
|
observe?.();
|
|
186
198
|
const plan = prepare(machine, doc, declared);
|
|
@@ -214,7 +226,7 @@ export function agree(machine: Machine, doc: unknown, context: Context = makeCon
|
|
|
214
226
|
if (options.other !== undefined) {
|
|
215
227
|
let given: Result | TierResult;
|
|
216
228
|
try {
|
|
217
|
-
given = options.other(doc, context,
|
|
229
|
+
given = options.other(doc, context, tierInput);
|
|
218
230
|
} catch (error) {
|
|
219
231
|
given = thrown(error, "the tier");
|
|
220
232
|
}
|