@elaraai/east 1.0.80 → 1.0.81

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.
Files changed (144) hide show
  1. package/dist/src/builtins.d.ts +1 -1
  2. package/dist/src/builtins.d.ts.map +1 -1
  3. package/dist/src/builtins.js +19 -0
  4. package/dist/src/builtins.js.map +1 -1
  5. package/dist/src/codegen/spellings.d.ts.map +1 -1
  6. package/dist/src/codegen/spellings.js +3 -0
  7. package/dist/src/codegen/spellings.js.map +1 -1
  8. package/dist/src/comparison.d.ts +54 -0
  9. package/dist/src/comparison.d.ts.map +1 -1
  10. package/dist/src/comparison.equivalent.spec.d.ts +6 -0
  11. package/dist/src/comparison.equivalent.spec.d.ts.map +1 -0
  12. package/dist/src/comparison.equivalent.spec.js +130 -0
  13. package/dist/src/comparison.equivalent.spec.js.map +1 -0
  14. package/dist/src/comparison.js +93 -20
  15. package/dist/src/comparison.js.map +1 -1
  16. package/dist/src/compile/builtins/array.d.ts +2 -1
  17. package/dist/src/compile/builtins/array.d.ts.map +1 -1
  18. package/dist/src/compile/builtins/array.js +35 -0
  19. package/dist/src/compile/builtins/array.js.map +1 -1
  20. package/dist/src/compile/builtins/dict.d.ts +1 -0
  21. package/dist/src/compile/builtins/dict.d.ts.map +1 -1
  22. package/dist/src/compile/builtins/dict.js +25 -0
  23. package/dist/src/compile/builtins/dict.js.map +1 -1
  24. package/dist/src/compile/builtins/set.d.ts +1 -0
  25. package/dist/src/compile/builtins/set.d.ts.map +1 -1
  26. package/dist/src/compile/builtins/set.js +25 -0
  27. package/dist/src/compile/builtins/set.js.map +1 -1
  28. package/dist/src/compile/builtins/tree.d.ts +32 -0
  29. package/dist/src/compile/builtins/tree.d.ts.map +1 -0
  30. package/dist/src/compile/builtins/tree.js +108 -0
  31. package/dist/src/compile/builtins/tree.js.map +1 -0
  32. package/dist/src/compile/functions.d.ts.map +1 -1
  33. package/dist/src/compile/functions.js +4 -4
  34. package/dist/src/compile/functions.js.map +1 -1
  35. package/dist/src/compile/runtime.d.ts +12 -15
  36. package/dist/src/compile/runtime.d.ts.map +1 -1
  37. package/dist/src/compile/runtime.js +19 -16
  38. package/dist/src/compile/runtime.js.map +1 -1
  39. package/dist/src/compile.signature.spec.d.ts +6 -0
  40. package/dist/src/compile.signature.spec.d.ts.map +1 -0
  41. package/dist/src/compile.signature.spec.js +53 -0
  42. package/dist/src/compile.signature.spec.js.map +1 -0
  43. package/dist/src/expr/array.d.ts +158 -81
  44. package/dist/src/expr/array.d.ts.map +1 -1
  45. package/dist/src/expr/array.js +68 -51
  46. package/dist/src/expr/array.js.map +1 -1
  47. package/dist/src/expr/ast.d.ts.map +1 -1
  48. package/dist/src/expr/ast.js +13 -0
  49. package/dist/src/expr/ast.js.map +1 -1
  50. package/dist/src/expr/blob.d.ts +8 -8
  51. package/dist/src/expr/blob.js +8 -8
  52. package/dist/src/expr/block.d.ts +18 -5
  53. package/dist/src/expr/block.d.ts.map +1 -1
  54. package/dist/src/expr/block.js +19 -0
  55. package/dist/src/expr/block.js.map +1 -1
  56. package/dist/src/expr/boolean.d.ts +10 -10
  57. package/dist/src/expr/boolean.js +10 -10
  58. package/dist/src/expr/datetime.d.ts +28 -28
  59. package/dist/src/expr/datetime.js +28 -28
  60. package/dist/src/expr/dict.d.ts +101 -51
  61. package/dist/src/expr/dict.d.ts.map +1 -1
  62. package/dist/src/expr/dict.js +97 -36
  63. package/dist/src/expr/dict.js.map +1 -1
  64. package/dist/src/expr/float.d.ts +23 -23
  65. package/dist/src/expr/float.js +23 -23
  66. package/dist/src/expr/integer.d.ts +17 -17
  67. package/dist/src/expr/integer.js +11 -11
  68. package/dist/src/expr/libs/array.d.ts +6 -6
  69. package/dist/src/expr/libs/array.js +6 -6
  70. package/dist/src/expr/libs/blob.d.ts +2 -2
  71. package/dist/src/expr/libs/blob.js +2 -2
  72. package/dist/src/expr/libs/datetime.d.ts +25 -25
  73. package/dist/src/expr/libs/datetime.js +25 -25
  74. package/dist/src/expr/libs/dict.d.ts +2 -2
  75. package/dist/src/expr/libs/dict.js +2 -2
  76. package/dist/src/expr/libs/float.d.ts +15 -15
  77. package/dist/src/expr/libs/float.js +15 -15
  78. package/dist/src/expr/libs/integer.d.ts +12 -12
  79. package/dist/src/expr/libs/integer.js +12 -12
  80. package/dist/src/expr/libs/set.d.ts +2 -2
  81. package/dist/src/expr/libs/set.js +2 -2
  82. package/dist/src/expr/libs/string.d.ts +4 -4
  83. package/dist/src/expr/libs/string.js +4 -4
  84. package/dist/src/expr/recursive.d.ts +22 -5
  85. package/dist/src/expr/recursive.d.ts.map +1 -1
  86. package/dist/src/expr/recursive.js +22 -5
  87. package/dist/src/expr/recursive.js.map +1 -1
  88. package/dist/src/expr/ref.d.ts +5 -5
  89. package/dist/src/expr/ref.js +5 -5
  90. package/dist/src/expr/set.d.ts +96 -51
  91. package/dist/src/expr/set.d.ts.map +1 -1
  92. package/dist/src/expr/set.js +85 -29
  93. package/dist/src/expr/set.js.map +1 -1
  94. package/dist/src/expr/string.d.ts +28 -28
  95. package/dist/src/expr/string.js +28 -28
  96. package/dist/src/expr/struct.d.ts.map +1 -1
  97. package/dist/src/expr/struct.js +2 -2
  98. package/dist/src/expr/variant.d.ts +12 -12
  99. package/dist/src/expr/variant.js +7 -7
  100. package/dist/src/function_symbols.d.ts +28 -0
  101. package/dist/src/function_symbols.d.ts.map +1 -0
  102. package/dist/src/function_symbols.js +28 -0
  103. package/dist/src/function_symbols.js.map +1 -0
  104. package/dist/src/location.d.ts +32 -0
  105. package/dist/src/location.d.ts.map +1 -1
  106. package/dist/src/location.js +38 -0
  107. package/dist/src/location.js.map +1 -1
  108. package/dist/src/location.spec.js +89 -1
  109. package/dist/src/location.spec.js.map +1 -1
  110. package/dist/src/runner_protocol.d.ts +46 -5
  111. package/dist/src/runner_protocol.d.ts.map +1 -1
  112. package/dist/src/runner_protocol.js +24 -5
  113. package/dist/src/runner_protocol.js.map +1 -1
  114. package/dist/src/serialization/beast2/index.d.ts +1 -0
  115. package/dist/src/serialization/beast2/index.d.ts.map +1 -1
  116. package/dist/src/serialization/beast2/index.js +1 -0
  117. package/dist/src/serialization/beast2/index.js.map +1 -1
  118. package/dist/src/serialization/beast2/v5/canonical.d.ts +101 -0
  119. package/dist/src/serialization/beast2/v5/canonical.d.ts.map +1 -0
  120. package/dist/src/serialization/beast2/v5/canonical.js +436 -0
  121. package/dist/src/serialization/beast2/v5/canonical.js.map +1 -0
  122. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts +6 -0
  123. package/dist/src/serialization/beast2/v5/canonical.spec.d.ts.map +1 -0
  124. package/dist/src/serialization/beast2/v5/canonical.spec.js +124 -0
  125. package/dist/src/serialization/beast2/v5/canonical.spec.js.map +1 -0
  126. package/dist/src/serialization/beast2/v5/elements.d.ts +3 -1
  127. package/dist/src/serialization/beast2/v5/elements.d.ts.map +1 -1
  128. package/dist/src/serialization/beast2/v5/elements.js +7 -2
  129. package/dist/src/serialization/beast2/v5/elements.js.map +1 -1
  130. package/dist/src/serialization/beast2/v5/elements.spec.js +1 -1
  131. package/dist/src/serialization/beast2/v5/elements.spec.js.map +1 -1
  132. package/dist/src/serialization/beast2/v5/intake.d.ts +98 -0
  133. package/dist/src/serialization/beast2/v5/intake.d.ts.map +1 -0
  134. package/dist/src/serialization/beast2/v5/intake.js +462 -0
  135. package/dist/src/serialization/beast2/v5/intake.js.map +1 -0
  136. package/dist/src/serialization/beast2/v5/intake.spec.d.ts +6 -0
  137. package/dist/src/serialization/beast2/v5/intake.spec.d.ts.map +1 -0
  138. package/dist/src/serialization/beast2/v5/intake.spec.js +202 -0
  139. package/dist/src/serialization/beast2/v5/intake.spec.js.map +1 -0
  140. package/dist/src/serialization/index.d.ts +1 -1
  141. package/dist/src/serialization/index.d.ts.map +1 -1
  142. package/dist/src/serialization/index.js +1 -1
  143. package/dist/src/serialization/index.js.map +1 -1
  144. package/package.json +1 -1
@@ -3,7 +3,7 @@
3
3
  * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
4
  */
5
5
  import type { AST } from "../ast.js";
6
- import { DictType, BooleanType, FunctionType, IntegerType, NullType, OptionType, SetType, NeverType, VariantType, FloatType, ArrayType } from "../types.js";
6
+ import { DictType, BooleanType, FunctionType, IntegerType, type EastType, NullType, OptionType, SetType, NeverType, VariantType, FloatType, ArrayType } from "../types.js";
7
7
  import type { BooleanExpr } from "./boolean.js";
8
8
  import type { IntegerExpr } from "./integer.js";
9
9
  import { Expr, type ToExpr } from "./expr.js";
@@ -29,7 +29,7 @@ import type { ArrayExpr } from "./array.js";
29
29
  * $(counts.merge(word, 1n, ($, existing, increment) => existing.add(increment), () => 0n));
30
30
  * $.return(null);
31
31
  * });
32
- * const compiled = East.compile(updateCounts.toIR(), []);
32
+ * const compiled = East.compile(updateCounts, []);
33
33
  * const counts = new Map([["hello", 5n], ["world", 3n]]);
34
34
  * compiled(counts, "hello"); // counts is now Map([["hello", 6n], ["world", 3n]])
35
35
  * compiled(counts, "new"); // counts is now Map([["hello", 6n], ["new", 1n], ["world", 3n]])
@@ -43,7 +43,7 @@ import type { ArrayExpr } from "./array.js";
43
43
  * const combine = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, a, b) => {
44
44
  * $.return(a.union(b, ($, existing, incoming) => existing.add(incoming)));
45
45
  * });
46
- * const compiled = East.compile(combine.toIR(), []);
46
+ * const compiled = East.compile(combine, []);
47
47
  * compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["b", 3n], ["c", 4n]]));
48
48
  * // Map([["a", 1n], ["b", 5n], ["c", 4n]]) — both inputs unchanged
49
49
  * ```
@@ -54,7 +54,7 @@ import type { ArrayExpr } from "./array.js";
54
54
  * const filterHighScores = East.function([DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, scores) => {
55
55
  * $.return(scores.filter(($, score, name) => score.greaterEqual(100n)));
56
56
  * });
57
- * const compiled = East.compile(filterHighScores.toIR(), []);
57
+ * const compiled = East.compile(filterHighScores, []);
58
58
  * const scores = new Map([["alice", 150n], ["bob", 75n], ["charlie", 200n]]);
59
59
  * compiled(scores); // Map([["alice", 150n], ["charlie", 200n]])
60
60
  * ```
@@ -73,7 +73,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
73
73
  * const getSize = East.function([DictType(StringType, IntegerType)], IntegerType, ($, dict) => {
74
74
  * $.return(dict.size());
75
75
  * });
76
- * const compiled = East.compile(getSize.toIR(), []);
76
+ * const compiled = East.compile(getSize, []);
77
77
  * compiled(new Map([["a", 1n], ["b", 2n], ["c", 3n]])); // 3n
78
78
  * compiled(new Map()); // 0n
79
79
  * ```
@@ -90,7 +90,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
90
90
  * const hasKey = East.function([DictType(StringType, IntegerType), StringType], BooleanType, ($, dict, key) => {
91
91
  * $.return(dict.has(key));
92
92
  * });
93
- * const compiled = East.compile(hasKey.toIR(), []);
93
+ * const compiled = East.compile(hasKey, []);
94
94
  * const dict = new Map([["a", 1n], ["b", 2n]]);
95
95
  * compiled(dict, "a"); // true
96
96
  * compiled(dict, "c"); // false
@@ -114,7 +114,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
114
114
  * const getValue = East.function([DictType(StringType, IntegerType), StringType], IntegerType, ($, dict, key) => {
115
115
  * $.return(dict.get(key));
116
116
  * });
117
- * const compiled = East.compile(getValue.toIR(), []);
117
+ * const compiled = East.compile(getValue, []);
118
118
  * const dict = new Map([["a", 1n], ["b", 2n]]);
119
119
  * compiled(dict, "a"); // 1n
120
120
  * // compiled(dict, "c") would throw error
@@ -126,7 +126,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
126
126
  * const getWithDefault = East.function([DictType(StringType, IntegerType), StringType], IntegerType, ($, dict, key) => {
127
127
  * $.return(dict.get(key, () => -1n));
128
128
  * });
129
- * const compiled = East.compile(getWithDefault.toIR(), []);
129
+ * const compiled = East.compile(getWithDefault, []);
130
130
  * compiled(dict, "a"); // 1n
131
131
  * compiled(dict, "c"); // -1n
132
132
  * ```
@@ -145,7 +145,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
145
145
  * const tryGetValue = East.function([DictType(StringType, IntegerType), StringType], OptionType(IntegerType), ($, dict, key) => {
146
146
  * $.return(dict.tryGet(key));
147
147
  * });
148
- * const compiled = East.compile(tryGetValue.toIR(), []);
148
+ * const compiled = East.compile(tryGetValue, []);
149
149
  * const dict = new Map([["a", 1n], ["b", 2n]]);
150
150
  * compiled(dict, "a"); // { tag: "some", value: 1n }
151
151
  * compiled(dict, "c"); // { tag: "none", value: null }
@@ -160,7 +160,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
160
160
  * none: () => 0n
161
161
  * }));
162
162
  * });
163
- * const compiled = East.compile(getOrDefault.toIR(), []);
163
+ * const compiled = East.compile(getOrDefault, []);
164
164
  * compiled(dict, "a"); // 1n
165
165
  * compiled(dict, "c"); // 0n
166
166
  * ```
@@ -185,7 +185,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
185
185
  * $(dict.insert(key, value));
186
186
  * $.return(null);
187
187
  * });
188
- * const compiled = East.compile(insertEntry.toIR(), []);
188
+ * const compiled = East.compile(insertEntry, []);
189
189
  * const dict = new Map([["a", 1n]]);
190
190
  * compiled(dict, "b", 2n); // dict now has Map([["a", 1n], ["b", 2n]])
191
191
  * // compiled(dict, "a", 10n) would throw error (duplicate key)
@@ -213,7 +213,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
213
213
  * $(dict.insertOrUpdate(key, value));
214
214
  * $.return(null);
215
215
  * });
216
- * const compiled = East.compile(upsert.toIR(), []);
216
+ * const compiled = East.compile(upsert, []);
217
217
  * const dict = new Map([["a", 1n]]);
218
218
  * compiled(dict, "b", 2n); // dict now has Map([["a", 1n], ["b", 2n]])
219
219
  * compiled(dict, "a", 10n); // dict now has Map([["a", 10n], ["b", 2n]])
@@ -239,7 +239,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
239
239
  * $(dict.update(key, newValue));
240
240
  * $.return(null);
241
241
  * });
242
- * const compiled = East.compile(updateValue.toIR(), []);
242
+ * const compiled = East.compile(updateValue, []);
243
243
  * const dict = new Map([["a", 1n], ["b", 2n]]);
244
244
  * compiled(dict, "a", 10n); // dict now has Map([["a", 10n], ["b", 2n]])
245
245
  * // compiled(dict, "c", 3n) would throw error (key not found)
@@ -279,7 +279,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
279
279
  * $(counts.merge(word, 1n, ($, existing, inc) => existing.add(inc), () => 0n));
280
280
  * $.return(null);
281
281
  * });
282
- * const compiled = East.compile(increment.toIR(), []);
282
+ * const compiled = East.compile(increment, []);
283
283
  * const counts = new Map([["hello", 5n]]);
284
284
  * compiled(counts, "hello"); // counts now has Map([["hello", 6n]])
285
285
  * compiled(counts, "world"); // counts now has Map([["hello", 6n], ["world", 1n]])
@@ -292,7 +292,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
292
292
  * $(dict.merge(key, suffix, ($, existing, newVal) => existing.concat(newVal), () => ""));
293
293
  * $.return(null);
294
294
  * });
295
- * const compiled = East.compile(appendText.toIR(), []);
295
+ * const compiled = East.compile(appendText, []);
296
296
  * const dict = new Map([["greeting", "Hello"]]);
297
297
  * compiled(dict, "greeting", " World"); // Map([["greeting", "Hello World"]])
298
298
  * compiled(dict, "new", "Hi"); // Map([["greeting", "Hello World"], ["new", "Hi"]])
@@ -317,7 +317,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
317
317
  * const getOrCreate = East.function([DictType(StringType, IntegerType), StringType], IntegerType, ($, dict, key) => {
318
318
  * $.return(dict.getOrInsert(key, () => 0n));
319
319
  * });
320
- * const compiled = East.compile(getOrCreate.toIR(), []);
320
+ * const compiled = East.compile(getOrCreate, []);
321
321
  * const dict = new Map([["a", 1n]]);
322
322
  * compiled(dict, "a"); // 1n (existing value)
323
323
  * compiled(dict, "b"); // 0n (new value inserted)
@@ -343,7 +343,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
343
343
  * $(dict.delete(key));
344
344
  * $.return(null);
345
345
  * });
346
- * const compiled = East.compile(deleteKey.toIR(), []);
346
+ * const compiled = East.compile(deleteKey, []);
347
347
  * const dict = new Map([["a", 1n], ["b", 2n]]);
348
348
  * compiled(dict, "a"); // dict now has Map([["b", 2n]])
349
349
  * // compiled(dict, "c") would throw error (key not found)
@@ -364,7 +364,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
364
364
  * const tryDeleteKey = East.function([DictType(StringType, IntegerType), StringType], BooleanType, ($, dict, key) => {
365
365
  * $.return(dict.tryDelete(key));
366
366
  * });
367
- * const compiled = East.compile(tryDeleteKey.toIR(), []);
367
+ * const compiled = East.compile(tryDeleteKey, []);
368
368
  * const dict = new Map([["a", 1n], ["b", 2n]]);
369
369
  * compiled(dict, "a"); // true (dict now has Map([["b", 2n]]))
370
370
  * compiled(dict, "c"); // false (key not found, dict unchanged)
@@ -387,7 +387,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
387
387
  * const popKey = East.function([DictType(StringType, IntegerType), StringType], IntegerType, ($, dict, key) => {
388
388
  * $.return(dict.pop(key));
389
389
  * });
390
- * const compiled = East.compile(popKey.toIR(), []);
390
+ * const compiled = East.compile(popKey, []);
391
391
  * const dict = new Map([["a", 1n], ["b", 2n]]);
392
392
  * compiled(dict, "a"); // 1n (dict now has Map([["b", 2n]]))
393
393
  * // compiled(dict, "c") would throw error (key not found)
@@ -411,7 +411,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
411
411
  * const swapValue = East.function([DictType(StringType, IntegerType), StringType, IntegerType], IntegerType, ($, dict, key, newValue) => {
412
412
  * $.return(dict.swap(key, newValue));
413
413
  * });
414
- * const compiled = East.compile(swapValue.toIR(), []);
414
+ * const compiled = East.compile(swapValue, []);
415
415
  * const dict = new Map([["a", 1n], ["b", 2n]]);
416
416
  * compiled(dict, "a", 10n); // 1n (dict now has Map([["a", 10n], ["b", 2n]]))
417
417
  * // compiled(dict, "c", 3n) would throw error (key not found)
@@ -431,7 +431,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
431
431
  * $(dict.clear());
432
432
  * $.return(null);
433
433
  * });
434
- * const compiled = East.compile(clearDict.toIR(), []);
434
+ * const compiled = East.compile(clearDict, []);
435
435
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
436
436
  * compiled(dict); // dict is now Map([])
437
437
  * ```
@@ -457,7 +457,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
457
457
  * $(dict1.unionInPlace(dict2, ($, existing, newVal) => existing.add(newVal)));
458
458
  * $.return(null);
459
459
  * });
460
- * const compiled = East.compile(unionDicts.toIR(), []);
460
+ * const compiled = East.compile(unionDicts, []);
461
461
  * const dict1 = new Map([["a", 1n], ["b", 2n]]);
462
462
  * const dict2 = new Map([["b", 3n], ["c", 4n]]);
463
463
  * compiled(dict1, dict2); // dict1 now has Map([["a", 1n], ["b", 5n], ["c", 4n]])
@@ -493,7 +493,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
493
493
  * const combine = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, dict1, dict2) => {
494
494
  * $.return(dict1.union(dict2, ($, existing, newVal) => existing.add(newVal)));
495
495
  * });
496
- * const compiled = East.compile(combine.toIR(), []);
496
+ * const compiled = East.compile(combine, []);
497
497
  * const dict1 = new Map([["a", 1n], ["b", 2n]]);
498
498
  * const dict2 = new Map([["b", 3n], ["c", 4n]]);
499
499
  * compiled(dict1, dict2); // Map([["a", 1n], ["b", 5n], ["c", 4n]]) — dict1 is unchanged
@@ -528,7 +528,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
528
528
  * $.return(null);
529
529
  * }
530
530
  * );
531
- * const compiled = East.compile(mergeCounts.toIR(), []);
531
+ * const compiled = East.compile(mergeCounts, []);
532
532
  * const counts1 = new Map([["apple", 5n], ["banana", 3n]]);
533
533
  * const counts2 = new Map([["banana", 2n], ["cherry", 7n]]);
534
534
  * compiled(counts1, counts2); // counts1 now has Map([["apple", 5n], ["banana", 5n], ["cherry", 7n]])
@@ -547,7 +547,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
547
547
  * const getKeys = East.function([DictType(StringType, IntegerType)], SetType(StringType), ($, dict) => {
548
548
  * $.return(dict.keys());
549
549
  * });
550
- * const compiled = East.compile(getKeys.toIR(), []);
550
+ * const compiled = East.compile(getKeys, []);
551
551
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
552
552
  * compiled(dict); // Set(["a", "b", "c"])
553
553
  * ```
@@ -569,7 +569,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
569
569
  * const selectKeys = East.function([DictType(StringType, IntegerType), SetType(StringType)], DictType(StringType, IntegerType), ($, dict, keysToSelect) => {
570
570
  * $.return(dict.getKeys(keysToSelect));
571
571
  * });
572
- * const compiled = East.compile(selectKeys.toIR(), []);
572
+ * const compiled = East.compile(selectKeys, []);
573
573
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n], ["d", 4n]]);
574
574
  * const keysToSelect = new Set(["a", "c"]);
575
575
  * compiled(dict, keysToSelect); // Map([["a", 1n], ["c", 3n]])
@@ -581,7 +581,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
581
581
  * const selectWithDefault = East.function([DictType(StringType, IntegerType), SetType(StringType)], DictType(StringType, IntegerType), ($, dict, keys) => {
582
582
  * $.return(dict.getKeys(keys, () => 0n));
583
583
  * });
584
- * const compiled = East.compile(selectWithDefault.toIR(), []);
584
+ * const compiled = East.compile(selectWithDefault, []);
585
585
  * const keysWithMissing = new Set(["a", "x"]);
586
586
  * compiled(dict, keysWithMissing); // Map([["a", 1n], ["x", 0n]])
587
587
  * ```
@@ -602,7 +602,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
602
602
  * }));
603
603
  * $.return(null);
604
604
  * });
605
- * const compiled = East.compile(printEntries.toIR(), []);
605
+ * const compiled = East.compile(printEntries, []);
606
606
  * const dict = new Map([["a", 1n], ["b", 2n]]);
607
607
  * compiled(dict); // Iterates over all entries
608
608
  * ```
@@ -618,7 +618,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
618
618
  * const copyDict = East.function([DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, dict) => {
619
619
  * $.return(dict.copy());
620
620
  * });
621
- * const compiled = East.compile(copyDict.toIR(), []);
621
+ * const compiled = East.compile(copyDict, []);
622
622
  * const dict = new Map([["a", 1n], ["b", 2n]]);
623
623
  * const copy = compiled(dict); // Map([["a", 1n], ["b", 2n]])
624
624
  * // Modifying copy doesn't affect dict
@@ -641,7 +641,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
641
641
  * const doubleValues = East.function([DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, dict) => {
642
642
  * $.return(dict.map(($, value, key) => value.multiply(2n)));
643
643
  * });
644
- * const compiled = East.compile(doubleValues.toIR(), []);
644
+ * const compiled = East.compile(doubleValues, []);
645
645
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
646
646
  * compiled(dict); // Map([["a", 2n], ["b", 4n], ["c", 6n]])
647
647
  * ```
@@ -662,7 +662,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
662
662
  * const filterLargeValues = East.function([DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, dict) => {
663
663
  * $.return(dict.filter(($, value, key) => value.greaterEqual(10n)));
664
664
  * });
665
- * const compiled = East.compile(filterLargeValues.toIR(), []);
665
+ * const compiled = East.compile(filterLargeValues, []);
666
666
  * const dict = new Map([["a", 5n], ["b", 15n], ["c", 20n], ["d", 8n]]);
667
667
  * compiled(dict); // Map([["b", 15n], ["c", 20n]])
668
668
  * ```
@@ -692,7 +692,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
692
692
  * )
693
693
  * ));
694
694
  * });
695
- * const compiled = East.compile(filterMapEven.toIR(), []);
695
+ * const compiled = East.compile(filterMapEven, []);
696
696
  * const dict = new Map([["a", 2n], ["b", 3n], ["c", 4n], ["d", 5n]]);
697
697
  * compiled(dict); // Map([["a", 1n], ["c", 2n]]) - only even values, halved
698
698
  * ```
@@ -715,7 +715,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
715
715
  * const dictToArray = East.function([DictType(StringType, IntegerType)], ArrayType(IntegerType), ($, dict) => {
716
716
  * $.return(dict.toArray()); // Just values
717
717
  * });
718
- * const compiled = East.compile(dictToArray.toIR(), []);
718
+ * const compiled = East.compile(dictToArray, []);
719
719
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
720
720
  * compiled(dict); // [1n, 2n, 3n]
721
721
  * ```
@@ -726,7 +726,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
726
726
  * const pairsToArray = East.function([DictType(StringType, IntegerType)], ArrayType(StringType), ($, dict) => {
727
727
  * $.return(dict.toArray(($, value, key) => Expr.str`${key}: ${value}`));
728
728
  * });
729
- * const compiled = East.compile(pairsToArray.toIR(), []);
729
+ * const compiled = East.compile(pairsToArray, []);
730
730
  * compiled(dict); // ["a: 1", "b: 2", "c: 3"]
731
731
  * ```
732
732
  */
@@ -749,7 +749,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
749
749
  * const extractCategories = East.function([DictType(StringType, StructType({category: StringType, price: IntegerType}))], SetType(StringType), ($, products) => {
750
750
  * $.return(products.toSet(($, product, name) => product.category));
751
751
  * });
752
- * const compiled = East.compile(extractCategories.toIR(), []);
752
+ * const compiled = East.compile(extractCategories, []);
753
753
  * const products = new Map([
754
754
  * ["apple", {category: "fruit", price: 100n}],
755
755
  * ["banana", {category: "fruit", price: 80n}],
@@ -784,7 +784,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
784
784
  * const uppercaseKeys = East.function([DictType(StringType, IntegerType)], DictType(StringType, IntegerType), ($, dict) => {
785
785
  * $.return(dict.toDict(($, value, key) => key.upperCase()));
786
786
  * });
787
- * const compiled = East.compile(uppercaseKeys.toIR(), []);
787
+ * const compiled = East.compile(uppercaseKeys, []);
788
788
  * const dict = new Map([["a", 1n], ["b", 2n]]);
789
789
  * compiled(dict); // Map([["A", 1n], ["B", 2n]])
790
790
  * ```
@@ -799,7 +799,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
799
799
  * ($, existing, newVal, len) => existing.add(newVal)
800
800
  * ));
801
801
  * });
802
- * const compiled = East.compile(groupByLength.toIR(), []);
802
+ * const compiled = East.compile(groupByLength, []);
803
803
  * const dict2 = new Map([["a", 1n], ["ab", 2n], ["c", 3n], ["def", 4n]]);
804
804
  * compiled(dict2); // Map([[1n, 4n], [2n, 2n], [3n, 4n]])
805
805
  * ```
@@ -834,7 +834,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
834
834
  * return arr;
835
835
  * }));
836
836
  * });
837
- * const compiled = East.compile(expandRanges.toIR(), []);
837
+ * const compiled = East.compile(expandRanges, []);
838
838
  * const dict = new Map([["a", 2n], ["b", 3n]]);
839
839
  * compiled(dict); // [0n, 1n, 0n, 1n, 2n] - flattened ranges
840
840
  * ```
@@ -860,7 +860,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
860
860
  * const getAllTags = East.function([DictType(StringType, ArrayType(StringType))], SetType(StringType), ($, articles) => {
861
861
  * $.return(articles.flattenToSet(($, tags, title) => tags.toSet()));
862
862
  * });
863
- * const compiled = East.compile(getAllTags.toIR(), []);
863
+ * const compiled = East.compile(getAllTags, []);
864
864
  * const articles = new Map([
865
865
  * ["Article 1", ["javascript", "programming"]],
866
866
  * ["Article 2", ["python", "programming"]],
@@ -894,7 +894,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
894
894
  * const mergeNestedDicts = East.function([DictType(StringType, DictType(StringType, IntegerType))], DictType(StringType, IntegerType), ($, nested) => {
895
895
  * $.return(nested.flattenToDict(undefined, ($, existing, newVal) => existing.add(newVal)));
896
896
  * });
897
- * const compiled = East.compile(mergeNestedDicts.toIR(), []);
897
+ * const compiled = East.compile(mergeNestedDicts, []);
898
898
  * const nested = new Map([
899
899
  * ["group1", new Map([["a", 1n], ["b", 2n]])],
900
900
  * ["group2", new Map([["b", 3n], ["c", 4n]])]
@@ -905,6 +905,56 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
905
905
  flattenToDict<K2, V2>(fn: Expr<FunctionType<[K], DictType<K2, V2>>>, onConflict?: SubtypeExprOrValue<FunctionType<[NoInfer<V2>, NoInfer<V2>, NoInfer<K2>], NoInfer<V2>>>): DictExpr<K2, V2>;
906
906
  flattenToDict<F extends (($: BlockBuilder<NeverType>, v: ExprType<T>, k: ExprType<K>) => any)>(fn: F, onConflict?: SubtypeExprOrValue<FunctionType<[TypeOf<ReturnType<NoInfer<F>>> extends DictType<any, infer V2> ? V2 : never, TypeOf<ReturnType<NoInfer<F>>> extends DictType<any, infer V2> ? V2 : never, TypeOf<ReturnType<NoInfer<F>>> extends DictType<infer K2, any> ? K2 : never], TypeOf<ReturnType<NoInfer<F>>> extends DictType<any, infer V2> ? V2 : never>>): TypeOf<ReturnType<F>> extends DictType<infer K2, infer V2> ? DictExpr<K2, V2> : never;
907
907
  flattenToDict(): T extends DictType<infer K2, infer V2> ? DictExpr<K2, V2> : never;
908
+ /**
909
+ * Builds a tree of any depth from the dictionary's entries, in a node type of your own; each entry's key is its key.
910
+ *
911
+ * `parentFn` names each entry's parent key; `buildFn` turns an entry and its children's built nodes into its
912
+ * node. The result is the roots.
913
+ *
914
+ * @param node - The node type `buildFn` returns; its `children` argument is an Array of it
915
+ * @param parentFn - Function taking (value, key) and returning the parent's key, or `none` for a root
916
+ * @param buildFn - Function taking (value, key, children) and returning the entry's node
917
+ * @returns An ArrayExpr of the root nodes, in key order
918
+ *
919
+ * @throws East runtime error if the parents form a cycle, naming the first key in key order on the cycle
920
+ *
921
+ * @remarks
922
+ * - An entry whose parent key is not in the dictionary (an orphan) becomes a root.
923
+ * - `buildFn` runs once per entry, children before parents; `children` holds the built children in key
924
+ * order. Every `parentFn` runs first, and the cycle check comes before any `buildFn`.
925
+ * - `node` can be any type: a recursive node type builds a tree value, a non-recursive one folds bottom-up.
926
+ * - The walk is iterative, so building costs no stack at any depth. A recursive node value is still limited
927
+ * in depth on the C and Python runtimes, which collect and free a value recursively: tens of thousands of
928
+ * levels.
929
+ *
930
+ * @example
931
+ * ```ts
932
+ * const EntryType = StructType({ name: StringType, parent: OptionType(StringType) });
933
+ * const NodeType = RecursiveType(self => StructType({ id: StringType, name: StringType, children: ArrayType(self) }));
934
+ *
935
+ * const nest = East.function([DictType(StringType, EntryType)], ArrayType(NodeType), ($, entries) => {
936
+ * $.return(entries.toTree(
937
+ * NodeType,
938
+ * ($, entry, id) => entry.parent,
939
+ * ($, entry, id, children) => ({ id, name: entry.name, children }),
940
+ * ));
941
+ * });
942
+ * const compiled = East.compile(nest, []);
943
+ * compiled(new Map([
944
+ * ["animals", { name: "Animals", parent: none }],
945
+ * ["birds", { name: "Birds", parent: some("animals") }],
946
+ * ["mammals", { name: "Mammals", parent: some("animals") }],
947
+ * ["whales", { name: "Whales", parent: some("mammals") }],
948
+ * ]));
949
+ * // [{ id: "animals", name: "Animals", children: [
950
+ * // { id: "birds", name: "Birds", children: [] },
951
+ * // { id: "mammals", name: "Mammals", children: [{ id: "whales", name: "Whales", children: [] }] },
952
+ * // ] }]
953
+ * ```
954
+ *
955
+ * @see {@link ArrayExpr.toTree} for elements that carry their own key.
956
+ */
957
+ toTree<N extends EastType>(node: N, parentFn: SubtypeExprOrValue<FunctionType<[T, K], OptionType<K>>>, buildFn: SubtypeExprOrValue<FunctionType<[T, K, ArrayType<NoInfer<N>>], NoInfer<N>>>): ArrayExpr<N>;
908
958
  /** Group entries by key and perform a fold/reduce operation on each group.
909
959
  *
910
960
  * @param keyFn - Function that maps each value and key to a group key
@@ -1122,7 +1172,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1122
1172
  * const sumValues = East.function([DictType(StringType, IntegerType)], IntegerType, ($, dict) => {
1123
1173
  * $.return(dict.reduce(($, acc, value, key) => acc.add(value), 0n));
1124
1174
  * });
1125
- * const compiled = East.compile(sumValues.toIR(), []);
1175
+ * const compiled = East.compile(sumValues, []);
1126
1176
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
1127
1177
  * compiled(dict); // 6n
1128
1178
  * ```
@@ -1133,7 +1183,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1133
1183
  * const concatKeys = East.function([DictType(StringType, IntegerType)], StringType, ($, dict) => {
1134
1184
  * $.return(dict.reduce(($, acc, value, key) => acc.concat(",").concat(key), ""));
1135
1185
  * });
1136
- * const compiled = East.compile(concatKeys.toIR(), []);
1186
+ * const compiled = East.compile(concatKeys, []);
1137
1187
  * compiled(dict); // ",a,b,c"
1138
1188
  * ```
1139
1189
  */
@@ -1156,7 +1206,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1156
1206
  * const runningTotal = East.function([DictType(StringType, IntegerType)], ArrayType(IntegerType), ($, dict) => {
1157
1207
  * $.return(dict.scan(($, acc, value, key) => acc.add(value), 0n));
1158
1208
  * });
1159
- * const compiled = East.compile(runningTotal.toIR(), []);
1209
+ * const compiled = East.compile(runningTotal, []);
1160
1210
  * compiled(new Map([["a", 1n], ["b", 2n], ["c", 3n]])); // [1n, 3n, 6n]
1161
1211
  * compiled(new Map()); // []
1162
1212
  * ```
@@ -1240,7 +1290,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1240
1290
  * const allPositive = East.function([DictType(StringType, IntegerType)], BooleanType, ($, dict) => {
1241
1291
  * $.return(dict.every(($, value, key) => value.greater(0n)));
1242
1292
  * });
1243
- * const compiled = East.compile(allPositive.toIR(), []);
1293
+ * const compiled = East.compile(allPositive, []);
1244
1294
  * const dict1 = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
1245
1295
  * compiled(dict1); // true
1246
1296
  * const dict2 = new Map([["a", 1n], ["b", -2n], ["c", 3n]]);
@@ -1266,7 +1316,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1266
1316
  * const hasNegative = East.function([DictType(StringType, IntegerType)], BooleanType, ($, dict) => {
1267
1317
  * $.return(dict.some(($, value, key) => value.less(0n)));
1268
1318
  * });
1269
- * const compiled = East.compile(hasNegative.toIR(), []);
1319
+ * const compiled = East.compile(hasNegative, []);
1270
1320
  * const dict1 = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
1271
1321
  * compiled(dict1); // false
1272
1322
  * const dict2 = new Map([["a", 1n], ["b", -2n], ["c", 3n]]);
@@ -1292,7 +1342,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1292
1342
  * const sumValues = East.function([DictType(StringType, IntegerType)], IntegerType, ($, dict) => {
1293
1343
  * $.return(dict.sum());
1294
1344
  * });
1295
- * const compiled = East.compile(sumValues.toIR(), []);
1345
+ * const compiled = East.compile(sumValues, []);
1296
1346
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n]]);
1297
1347
  * compiled(dict); // 6n
1298
1348
  * ```
@@ -1303,7 +1353,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1303
1353
  * const sumLengths = East.function([DictType(StringType, StringType)], IntegerType, ($, dict) => {
1304
1354
  * $.return(dict.sum(($, value, key) => value.length()));
1305
1355
  * });
1306
- * const compiled = East.compile(sumLengths.toIR(), []);
1356
+ * const compiled = East.compile(sumLengths, []);
1307
1357
  * const dict2 = new Map([["a", "hello"], ["b", "world"]]);
1308
1358
  * compiled(dict2); // 10n (5 + 5)
1309
1359
  * ```
@@ -1329,7 +1379,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1329
1379
  * const avgValue = East.function([DictType(StringType, IntegerType)], FloatType, ($, dict) => {
1330
1380
  * $.return(dict.mean());
1331
1381
  * });
1332
- * const compiled = East.compile(avgValue.toIR(), []);
1382
+ * const compiled = East.compile(avgValue, []);
1333
1383
  * const dict = new Map([["a", 1n], ["b", 2n], ["c", 3n], ["d", 4n]]);
1334
1384
  * compiled(dict); // 2.5
1335
1385
  * ```
@@ -1340,7 +1390,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1340
1390
  * const avgLength = East.function([DictType(StringType, StringType)], FloatType, ($, dict) => {
1341
1391
  * $.return(dict.mean(($, value, key) => value.length()));
1342
1392
  * });
1343
- * const compiled = East.compile(avgLength.toIR(), []);
1393
+ * const compiled = East.compile(avgLength, []);
1344
1394
  * const dict2 = new Map([["a", "hi"], ["b", "hello"], ["c", "hey"]]);
1345
1395
  * compiled(dict2); // 3.3333333333333335 (average of 2, 5, 3)
1346
1396
  * ```
@@ -1360,7 +1410,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1360
1410
  * const isEqual = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], BooleanType, ($, a, b) => {
1361
1411
  * $.return(a.equals(b));
1362
1412
  * });
1363
- * const compiled = East.compile(isEqual.toIR(), []);
1413
+ * const compiled = East.compile(isEqual, []);
1364
1414
  * compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["a", 1n], ["b", 2n]])); // true
1365
1415
  * compiled(new Map([["a", 1n]]), new Map([["a", 1n], ["b", 2n]])); // false
1366
1416
  * ```
@@ -1377,7 +1427,7 @@ export declare class DictExpr<K extends any, T extends any> extends Expr<DictTyp
1377
1427
  * const isNotEqual = East.function([DictType(StringType, IntegerType), DictType(StringType, IntegerType)], BooleanType, ($, a, b) => {
1378
1428
  * $.return(a.notEquals(b));
1379
1429
  * });
1380
- * const compiled = East.compile(isNotEqual.toIR(), []);
1430
+ * const compiled = East.compile(isNotEqual, []);
1381
1431
  * compiled(new Map([["a", 1n]]), new Map([["a", 1n], ["b", 2n]])); // true
1382
1432
  * compiled(new Map([["a", 1n], ["b", 2n]]), new Map([["a", 1n], ["b", 2n]])); // false
1383
1433
  * ```