@mark1russell7/vex-compiler 0.9.1 → 0.10.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@mark1russell7/vex-compiler",
4
- "version": "0.9.1",
4
+ "version": "0.10.0",
5
5
  "description": "The Vex compiler: generated JavaScript for Vex programs, at run time and at build time, with the results of the interpreter.",
6
6
  "keywords": [
7
7
  "vex",
@@ -43,15 +43,15 @@
43
43
  },
44
44
  "devDependencies": {
45
45
  "@mark1russell7/cue": "github:mark1russell7/cue",
46
- "@mark1russell7/vex-domains": "0.9.1",
47
- "@mark1russell7/vex-testkit": "0.9.1",
46
+ "@mark1russell7/vex-domains": "0.10.0",
47
+ "@mark1russell7/vex-testkit": "0.10.0",
48
48
  "@types/node": "^26.6.4",
49
49
  "fast-check": "^4.10.2",
50
50
  "typescript": "^7.0.2",
51
51
  "vitest": "^5.0.3"
52
52
  },
53
53
  "dependencies": {
54
- "@mark1russell7/vex": "0.9.1"
54
+ "@mark1russell7/vex": "0.10.0"
55
55
  },
56
56
  "scripts": {
57
57
  "build": "tsdown",
package/src/facts.ts CHANGED
@@ -11,8 +11,8 @@ import { children, isListOp, isOpName, liftsAt, listOf, type AnyDomain, type Exp
11
11
  */
12
12
  export const MAX_CALLS = 10_000;
13
13
 
14
- /** The list ops that give a list or read a position of a list (LIST.SORT, LIST.TAKE, LIST.NTH). */
15
- const ORDER_OPS: ReadonlySet<string> = new Set(["sortBy", "take", "nth"]);
14
+ /** The list ops that give a list or read a position of a list (LIST.SORT, LIST.TAKE, LIST.NTH, LIST.BUILD). */
15
+ const ORDER_OPS: ReadonlySet<string> = new Set(["sortBy", "take", "nth", "drop", "append", "flat", "without"]);
16
16
 
17
17
  /**
18
18
  * This function gives the reason that tier 2 cannot take a program with lists as values. The reason is the axis `list`
package/src/lower.ts CHANGED
@@ -563,6 +563,10 @@ class Lowerer {
563
563
  case "sortBy":
564
564
  case "take":
565
565
  case "nth":
566
+ case "drop":
567
+ case "append":
568
+ case "flat":
569
+ case "without":
566
570
  /* v8 ignore next -- @preserve */
567
571
  // Stryker disable next-line all: listReason stops these ops before the lowering
568
572
  throw new Unsupported(`the list op "${op}"`);
package/src/module.ts CHANGED
@@ -369,6 +369,8 @@ const NEEDS: Readonly<Record<Helper, readonly Helper[]>> = {
369
369
  const LIST_OPS: ReadonlySet<string> = new Set(["count", "sum", "mean", "min", "max", "any", "all", "none", "first"]);
370
370
  const NUMBER_LIST_OPS: ReadonlySet<string> = new Set(["count", "sum", "mean", "min", "max"]);
371
371
  const BOOLEAN_LIST_OPS: ReadonlySet<string> = new Set(["any", "all", "none"]);
372
+ /** The list ops that build a list from lists (LIST.BUILD). A module gives a reason for them. */
373
+ const BUILD_OPS: ReadonlySet<string> = new Set(["drop", "append", "flat", "without"]);
372
374
 
373
375
  /** This function gives the kind of the result of a list op: first gives the kind of its items. */
374
376
  const listKind = (op: string, item: Kind | undefined): Kind | undefined => (NUMBER_LIST_OPS.has(op) ? "number" : BOOLEAN_LIST_OPS.has(op) ? "boolean" : item);
@@ -1194,6 +1196,8 @@ class Printer {
1194
1196
  const [head] = args;
1195
1197
  if (LIST_OPS.has(op) && head?.tag === "each") return this.#list(op, head, args.slice(1), ctx);
1196
1198
  if (head !== undefined && (op === "sortBy" || op === "take")) return this.#order(op, head, args.slice(1), ctx);
1199
+ // LIST.BUILD: a module does not have the ops that build a list yet. The interpreter evaluates them.
1200
+ if (head !== undefined && BUILD_OPS.has(op) && this.#isList(head, ctx)) throw new NotStandalone(`the list op "${op}" is not in a module yet`);
1197
1201
  if (head !== undefined && (LIST_OPS.has(op) || op === "nth") && this.#isList(head, ctx)) return this.#overList(op, head, args.slice(1), ctx);
1198
1202
  const raw = args.map((x) => this.expr(x, ctx));
1199
1203
  const deps = depsOf(...raw);