@elaraai/east 0.0.1-beta.3 → 0.0.1-beta.30

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 (190) hide show
  1. package/LICENSE.md +15 -666
  2. package/README.md +30 -8
  3. package/dist/src/analyze.d.ts +3 -0
  4. package/dist/src/analyze.d.ts.map +1 -1
  5. package/dist/src/analyze.js +52 -13
  6. package/dist/src/analyze.js.map +1 -1
  7. package/dist/src/ast.d.ts +34 -33
  8. package/dist/src/ast.d.ts.map +1 -1
  9. package/dist/src/ast_to_ir.d.ts +6 -0
  10. package/dist/src/ast_to_ir.d.ts.map +1 -1
  11. package/dist/src/ast_to_ir.js +134 -101
  12. package/dist/src/ast_to_ir.js.map +1 -1
  13. package/dist/src/builtins.d.ts +1 -1
  14. package/dist/src/builtins.d.ts.map +1 -1
  15. package/dist/src/builtins.js +32 -0
  16. package/dist/src/builtins.js.map +1 -1
  17. package/dist/src/comparison.d.ts.map +1 -1
  18. package/dist/src/comparison.js +12 -4
  19. package/dist/src/comparison.js.map +1 -1
  20. package/dist/src/compile.d.ts +26 -1
  21. package/dist/src/compile.d.ts.map +1 -1
  22. package/dist/src/compile.js +374 -257
  23. package/dist/src/compile.js.map +1 -1
  24. package/dist/src/datetime_format/types.d.ts +23 -23
  25. package/dist/src/eastir.d.ts.map +1 -1
  26. package/dist/src/eastir.js +21 -5
  27. package/dist/src/eastir.js.map +1 -1
  28. package/dist/src/error.d.ts +12 -1
  29. package/dist/src/error.d.ts.map +1 -1
  30. package/dist/src/error.js +31 -1
  31. package/dist/src/error.js.map +1 -1
  32. package/dist/src/expr/array.d.ts +109 -1
  33. package/dist/src/expr/array.d.ts.map +1 -1
  34. package/dist/src/expr/array.js +204 -44
  35. package/dist/src/expr/array.js.map +1 -1
  36. package/dist/src/expr/ast.d.ts +1 -1
  37. package/dist/src/expr/ast.d.ts.map +1 -1
  38. package/dist/src/expr/ast.js +16 -28
  39. package/dist/src/expr/ast.js.map +1 -1
  40. package/dist/src/expr/asyncfunction.js +1 -1
  41. package/dist/src/expr/asyncfunction.js.map +1 -1
  42. package/dist/src/expr/blob.d.ts +73 -1
  43. package/dist/src/expr/blob.d.ts.map +1 -1
  44. package/dist/src/expr/blob.js +97 -7
  45. package/dist/src/expr/blob.js.map +1 -1
  46. package/dist/src/expr/block.d.ts +206 -8
  47. package/dist/src/expr/block.d.ts.map +1 -1
  48. package/dist/src/expr/block.js +623 -136
  49. package/dist/src/expr/block.js.map +1 -1
  50. package/dist/src/expr/boolean.d.ts +44 -0
  51. package/dist/src/expr/boolean.d.ts.map +1 -1
  52. package/dist/src/expr/boolean.js +57 -5
  53. package/dist/src/expr/boolean.js.map +1 -1
  54. package/dist/src/expr/datetime.d.ts +135 -0
  55. package/dist/src/expr/datetime.d.ts.map +1 -1
  56. package/dist/src/expr/datetime.js +183 -33
  57. package/dist/src/expr/datetime.js.map +1 -1
  58. package/dist/src/expr/dict.d.ts +42 -0
  59. package/dist/src/expr/dict.d.ts.map +1 -1
  60. package/dist/src/expr/dict.js +105 -55
  61. package/dist/src/expr/dict.js.map +1 -1
  62. package/dist/src/expr/expr.d.ts +1 -1
  63. package/dist/src/expr/expr.d.ts.map +1 -1
  64. package/dist/src/expr/expr.js.map +1 -1
  65. package/dist/src/expr/float.d.ts +153 -0
  66. package/dist/src/expr/float.d.ts.map +1 -1
  67. package/dist/src/expr/float.js +190 -16
  68. package/dist/src/expr/float.js.map +1 -1
  69. package/dist/src/expr/function.d.ts +7 -2
  70. package/dist/src/expr/function.d.ts.map +1 -1
  71. package/dist/src/expr/function.js +1 -1
  72. package/dist/src/expr/function.js.map +1 -1
  73. package/dist/src/expr/index.d.ts +202 -2
  74. package/dist/src/expr/index.d.ts.map +1 -1
  75. package/dist/src/expr/index.js +207 -2
  76. package/dist/src/expr/index.js.map +1 -1
  77. package/dist/src/expr/integer.d.ts +180 -0
  78. package/dist/src/expr/integer.d.ts.map +1 -1
  79. package/dist/src/expr/integer.js +188 -17
  80. package/dist/src/expr/integer.js.map +1 -1
  81. package/dist/src/expr/libs/blob.js +2 -2
  82. package/dist/src/expr/libs/blob.js.map +1 -1
  83. package/dist/src/expr/libs/integer.d.ts +19 -0
  84. package/dist/src/expr/libs/integer.d.ts.map +1 -1
  85. package/dist/src/expr/libs/integer.js +47 -0
  86. package/dist/src/expr/libs/integer.js.map +1 -1
  87. package/dist/src/expr/libs/string.js +1 -1
  88. package/dist/src/expr/libs/string.js.map +1 -1
  89. package/dist/src/expr/recursive.d.ts +83 -0
  90. package/dist/src/expr/recursive.d.ts.map +1 -0
  91. package/dist/src/expr/recursive.js +99 -0
  92. package/dist/src/expr/recursive.js.map +1 -0
  93. package/dist/src/expr/ref.js +3 -3
  94. package/dist/src/expr/ref.js.map +1 -1
  95. package/dist/src/expr/set.d.ts +44 -2
  96. package/dist/src/expr/set.d.ts.map +1 -1
  97. package/dist/src/expr/set.js +97 -47
  98. package/dist/src/expr/set.js.map +1 -1
  99. package/dist/src/expr/string.d.ts +134 -0
  100. package/dist/src/expr/string.d.ts.map +1 -1
  101. package/dist/src/expr/string.js +172 -22
  102. package/dist/src/expr/string.js.map +1 -1
  103. package/dist/src/expr/struct.d.ts +1 -1
  104. package/dist/src/expr/struct.d.ts.map +1 -1
  105. package/dist/src/expr/struct.js +1 -1
  106. package/dist/src/expr/struct.js.map +1 -1
  107. package/dist/src/expr/types.d.ts +7 -6
  108. package/dist/src/expr/types.d.ts.map +1 -1
  109. package/dist/src/expr/variant.d.ts +123 -1
  110. package/dist/src/expr/variant.d.ts.map +1 -1
  111. package/dist/src/expr/variant.js +66 -2
  112. package/dist/src/expr/variant.js.map +1 -1
  113. package/dist/src/fuzz.d.ts +36 -2
  114. package/dist/src/fuzz.d.ts.map +1 -1
  115. package/dist/src/fuzz.js +344 -77
  116. package/dist/src/fuzz.js.map +1 -1
  117. package/dist/src/index.d.ts +1 -0
  118. package/dist/src/index.d.ts.map +1 -1
  119. package/dist/src/index.js +1 -0
  120. package/dist/src/index.js.map +1 -1
  121. package/dist/src/internal.d.ts +12 -0
  122. package/dist/src/internal.d.ts.map +1 -1
  123. package/dist/src/internal.js +13 -0
  124. package/dist/src/internal.js.map +1 -1
  125. package/dist/src/ir.d.ts +1547 -1505
  126. package/dist/src/ir.d.ts.map +1 -1
  127. package/dist/src/ir.js +49 -34
  128. package/dist/src/ir.js.map +1 -1
  129. package/dist/src/location.d.ts +30 -10
  130. package/dist/src/location.d.ts.map +1 -1
  131. package/dist/src/location.js +70 -28
  132. package/dist/src/location.js.map +1 -1
  133. package/dist/src/patch/apply.d.ts +15 -0
  134. package/dist/src/patch/apply.d.ts.map +1 -0
  135. package/dist/src/patch/apply.js +380 -0
  136. package/dist/src/patch/apply.js.map +1 -0
  137. package/dist/src/patch/compose.d.ts +15 -0
  138. package/dist/src/patch/compose.d.ts.map +1 -0
  139. package/dist/src/patch/compose.js +480 -0
  140. package/dist/src/patch/compose.js.map +1 -0
  141. package/dist/src/patch/diff.d.ts +15 -0
  142. package/dist/src/patch/diff.d.ts.map +1 -0
  143. package/dist/src/patch/diff.js +328 -0
  144. package/dist/src/patch/diff.js.map +1 -0
  145. package/dist/src/patch/fuzz.d.ts +73 -0
  146. package/dist/src/patch/fuzz.d.ts.map +1 -0
  147. package/dist/src/patch/fuzz.js +159 -0
  148. package/dist/src/patch/fuzz.js.map +1 -0
  149. package/dist/src/patch/index.d.ts +18 -0
  150. package/dist/src/patch/index.d.ts.map +1 -0
  151. package/dist/src/patch/index.js +20 -0
  152. package/dist/src/patch/index.js.map +1 -0
  153. package/dist/src/patch/invert.d.ts +15 -0
  154. package/dist/src/patch/invert.d.ts.map +1 -0
  155. package/dist/src/patch/invert.js +302 -0
  156. package/dist/src/patch/invert.js.map +1 -0
  157. package/dist/src/patch/type_of_patch.d.ts +17 -0
  158. package/dist/src/patch/type_of_patch.d.ts.map +1 -0
  159. package/dist/src/patch/type_of_patch.js +143 -0
  160. package/dist/src/patch/type_of_patch.js.map +1 -0
  161. package/dist/src/patch/types.d.ts +166 -0
  162. package/dist/src/patch/types.d.ts.map +1 -0
  163. package/dist/src/patch/types.js +69 -0
  164. package/dist/src/patch/types.js.map +1 -0
  165. package/dist/src/platform.d.ts +6 -0
  166. package/dist/src/platform.d.ts.map +1 -1
  167. package/dist/src/serialization/beast.d.ts.map +1 -1
  168. package/dist/src/serialization/beast.js +53 -18
  169. package/dist/src/serialization/beast.js.map +1 -1
  170. package/dist/src/serialization/beast2.d.ts +39 -3
  171. package/dist/src/serialization/beast2.d.ts.map +1 -1
  172. package/dist/src/serialization/beast2.js +241 -18
  173. package/dist/src/serialization/beast2.js.map +1 -1
  174. package/dist/src/serialization/csv.d.ts +139 -0
  175. package/dist/src/serialization/csv.d.ts.map +1 -0
  176. package/dist/src/serialization/csv.js +615 -0
  177. package/dist/src/serialization/csv.js.map +1 -0
  178. package/dist/src/serialization/index.d.ts +2 -1
  179. package/dist/src/serialization/index.d.ts.map +1 -1
  180. package/dist/src/serialization/index.js +2 -1
  181. package/dist/src/serialization/index.js.map +1 -1
  182. package/dist/src/type_of_type.d.ts +45 -34
  183. package/dist/src/type_of_type.d.ts.map +1 -1
  184. package/dist/src/type_of_type.js +62 -1
  185. package/dist/src/type_of_type.js.map +1 -1
  186. package/dist/src/types.d.ts +8 -8
  187. package/dist/src/types.d.ts.map +1 -1
  188. package/dist/src/types.js +4 -4
  189. package/dist/src/types.js.map +1 -1
  190. package/package.json +4 -5
@@ -2,7 +2,10 @@ import { get_location } from "../location.js";
2
2
  import { ArrayType, BooleanType, FunctionType, IntegerType, NullType, StringType, isSubtype, isTypeEqual, printType, NeverType, OptionType, isDataType, StructType, VariantType, SetType, FloatType, DictType } from "../types.js";
3
3
  import { valueOrExprToAst, valueOrExprToAstTyped } from "./ast.js";
4
4
  import { AstSymbol, Expr, FactorySymbol, TypeSymbol } from "./expr.js";
5
+ import { equal, notEqual } from "./block.js";
5
6
  import { none, some } from "../containers/variant.js";
7
+ import { CsvSerializeConfigType, csvSerializeOptionsToValue } from "../serialization/csv.js";
8
+ import { BlobType } from "../types.js";
6
9
  /**
7
10
  * Expression representing mutable array values and operations.
8
11
  *
@@ -56,7 +59,32 @@ export class ArrayExpr extends Expr {
56
59
  return this[FactorySymbol]({
57
60
  ast_type: "Builtin",
58
61
  type: IntegerType,
59
- location: get_location(2),
62
+ location: get_location(),
63
+ builtin: "ArraySize",
64
+ type_parameters: [this.value_type],
65
+ arguments: [this[AstSymbol]],
66
+ });
67
+ }
68
+ /**
69
+ * Returns the length of the array (an alias for size).
70
+ *
71
+ * @returns An IntegerExpr representing the number of elements
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const getLength = East.function([ArrayType(IntegerType)], IntegerType, ($, arr) => {
76
+ * $.return(arr.length());
77
+ * });
78
+ * const compiled = East.compile(getLength.toIR(), []);
79
+ * compiled([1n, 2n, 3n]); // 3n
80
+ * compiled([]); // 0n
81
+ * ```
82
+ */
83
+ length() {
84
+ return this[FactorySymbol]({
85
+ ast_type: "Builtin",
86
+ type: IntegerType,
87
+ location: get_location(),
60
88
  builtin: "ArraySize",
61
89
  type_parameters: [this.value_type],
62
90
  arguments: [this[AstSymbol]],
@@ -84,7 +112,7 @@ export class ArrayExpr extends Expr {
84
112
  return this[FactorySymbol]({
85
113
  ast_type: "Builtin",
86
114
  type: BooleanType,
87
- location: get_location(2),
115
+ location: get_location(),
88
116
  builtin: "ArrayHas",
89
117
  type_parameters: [this.value_type],
90
118
  arguments: [this[AstSymbol], keyAst],
@@ -123,7 +151,7 @@ export class ArrayExpr extends Expr {
123
151
  return this[FactorySymbol]({
124
152
  ast_type: "Builtin",
125
153
  type: this.value_type,
126
- location: get_location(2),
154
+ location: get_location(),
127
155
  builtin: "ArrayGetOrDefault",
128
156
  type_parameters: [this.value_type],
129
157
  arguments: [this[AstSymbol], keyAst, defaultFnAst],
@@ -133,7 +161,57 @@ export class ArrayExpr extends Expr {
133
161
  return this[FactorySymbol]({
134
162
  ast_type: "Builtin",
135
163
  type: this.value_type,
136
- location: get_location(2),
164
+ location: get_location(),
165
+ builtin: "ArrayGet",
166
+ type_parameters: [this.value_type],
167
+ arguments: [this[AstSymbol], keyAst],
168
+ });
169
+ }
170
+ }
171
+ /**
172
+ * Gets the element at the specified index (alias for get).
173
+ *
174
+ * @param key - The zero-based index
175
+ * @param defaultFn - Optional function to provide a default value for out-of-bounds indices
176
+ * @returns An expression of the array's element type
177
+ *
178
+ * @throws East runtime error if index is out of bounds and no defaultFn is provided
179
+ *
180
+ * @example
181
+ * ```ts
182
+ * const getElement = East.function([ArrayType(IntegerType), IntegerType], IntegerType, ($, arr, index) => {
183
+ * $.return(arr.get(index));
184
+ * });
185
+ * const compiled = East.compile(getElement.toIR(), []);
186
+ * compiled([10n, 20n, 30n], 1n); // 20n
187
+ * // compiled([10n, 20n, 30n], 5n) would throw error
188
+ *
189
+ * // With default value
190
+ * const getOrDefault = East.function([ArrayType(IntegerType), IntegerType], IntegerType, ($, arr, index) => {
191
+ * $.return(arr.get(index, ($, i) => -1n));
192
+ * });
193
+ * compiled = East.compile(getOrDefault.toIR(), []);
194
+ * compiled([10n, 20n, 30n], 5n); // -1n (out of bounds)
195
+ * ```
196
+ */
197
+ at(key, defaultFn) {
198
+ const keyAst = valueOrExprToAstTyped(key, IntegerType);
199
+ if (defaultFn !== undefined) {
200
+ const defaultFnAst = valueOrExprToAstTyped(defaultFn, FunctionType([IntegerType], this.value_type));
201
+ return this[FactorySymbol]({
202
+ ast_type: "Builtin",
203
+ type: this.value_type,
204
+ location: get_location(),
205
+ builtin: "ArrayGetOrDefault",
206
+ type_parameters: [this.value_type],
207
+ arguments: [this[AstSymbol], keyAst, defaultFnAst],
208
+ });
209
+ }
210
+ else {
211
+ return this[FactorySymbol]({
212
+ ast_type: "Builtin",
213
+ type: this.value_type,
214
+ location: get_location(),
137
215
  builtin: "ArrayGet",
138
216
  type_parameters: [this.value_type],
139
217
  arguments: [this[AstSymbol], keyAst],
@@ -161,7 +239,7 @@ export class ArrayExpr extends Expr {
161
239
  return this[FactorySymbol]({
162
240
  ast_type: "Builtin",
163
241
  type: OptionType(this.value_type),
164
- location: get_location(2),
242
+ location: get_location(),
165
243
  builtin: "ArrayTryGet",
166
244
  type_parameters: [this.value_type],
167
245
  arguments: [this[AstSymbol], keyAst],
@@ -192,7 +270,7 @@ export class ArrayExpr extends Expr {
192
270
  return this[FactorySymbol]({
193
271
  ast_type: "Builtin",
194
272
  type: NullType,
195
- location: get_location(2),
273
+ location: get_location(),
196
274
  builtin: "ArrayUpdate",
197
275
  type_parameters: [this.value_type],
198
276
  arguments: [this[AstSymbol], keyAst, valueAst],
@@ -205,7 +283,7 @@ export class ArrayExpr extends Expr {
205
283
  * @see {@link update} for simply replacing the value.
206
284
  */
207
285
  merge(key, value, updateFn) {
208
- const location = get_location(2);
286
+ const location = get_location();
209
287
  const keyAst = valueOrExprToAstTyped(key, IntegerType);
210
288
  const value2Type = value[TypeSymbol];
211
289
  const updateFnExpr = Expr.from(updateFn, FunctionType([value2Type, this.value_type, IntegerType], this.value_type));
@@ -239,7 +317,7 @@ export class ArrayExpr extends Expr {
239
317
  return this[FactorySymbol]({
240
318
  ast_type: "Builtin",
241
319
  type: NullType,
242
- location: get_location(2),
320
+ location: get_location(),
243
321
  builtin: "ArrayPushLast",
244
322
  type_parameters: [this.value_type],
245
323
  arguments: [this[AstSymbol], valueAst],
@@ -265,7 +343,7 @@ export class ArrayExpr extends Expr {
265
343
  return this[FactorySymbol]({
266
344
  ast_type: "Builtin",
267
345
  type: this.value_type,
268
- location: get_location(2),
346
+ location: get_location(),
269
347
  builtin: "ArrayPopLast",
270
348
  type_parameters: [this.value_type],
271
349
  arguments: [this[AstSymbol]],
@@ -292,7 +370,7 @@ export class ArrayExpr extends Expr {
292
370
  return this[FactorySymbol]({
293
371
  ast_type: "Builtin",
294
372
  type: NullType,
295
- location: get_location(2),
373
+ location: get_location(),
296
374
  builtin: "ArrayPushFirst",
297
375
  type_parameters: [this.value_type],
298
376
  arguments: [this[AstSymbol], valueAst],
@@ -318,7 +396,7 @@ export class ArrayExpr extends Expr {
318
396
  return this[FactorySymbol]({
319
397
  ast_type: "Builtin",
320
398
  type: this.value_type,
321
- location: get_location(2),
399
+ location: get_location(),
322
400
  builtin: "ArrayPopFirst",
323
401
  type_parameters: [this.value_type],
324
402
  arguments: [this[AstSymbol]],
@@ -345,7 +423,7 @@ export class ArrayExpr extends Expr {
345
423
  return this[FactorySymbol]({
346
424
  ast_type: "Builtin",
347
425
  type: NullType,
348
- location: get_location(2),
426
+ location: get_location(),
349
427
  builtin: "ArrayAppend",
350
428
  type_parameters: [this.value_type],
351
429
  arguments: [this[AstSymbol], arrayExpr[AstSymbol]],
@@ -373,7 +451,7 @@ export class ArrayExpr extends Expr {
373
451
  return this[FactorySymbol]({
374
452
  ast_type: "Builtin",
375
453
  type: NullType,
376
- location: get_location(2),
454
+ location: get_location(),
377
455
  builtin: "ArrayPrepend",
378
456
  type_parameters: [this.value_type],
379
457
  arguments: [this[AstSymbol], arrayExpr[AstSymbol]],
@@ -421,7 +499,7 @@ export class ArrayExpr extends Expr {
421
499
  return this[FactorySymbol]({
422
500
  ast_type: "Builtin",
423
501
  type: NullType,
424
- location: get_location(2),
502
+ location: get_location(),
425
503
  builtin: "ArrayMergeAll",
426
504
  type_parameters: [this.value_type, value2Type],
427
505
  arguments: [this[AstSymbol], array[AstSymbol], mergeFnExpr[AstSymbol]],
@@ -446,7 +524,7 @@ export class ArrayExpr extends Expr {
446
524
  return this[FactorySymbol]({
447
525
  ast_type: "Builtin",
448
526
  type: NullType,
449
- location: get_location(2),
527
+ location: get_location(),
450
528
  builtin: "ArrayClear",
451
529
  type_parameters: [this.value_type],
452
530
  arguments: [this[AstSymbol]],
@@ -502,7 +580,7 @@ export class ArrayExpr extends Expr {
502
580
  return this[FactorySymbol]({
503
581
  ast_type: "Builtin",
504
582
  type: NullType,
505
- location: get_location(2),
583
+ location: get_location(),
506
584
  builtin: "ArraySortInPlace",
507
585
  type_parameters: [this.value_type, projectedType],
508
586
  arguments: [this[AstSymbol], byExpr[AstSymbol]],
@@ -557,7 +635,7 @@ export class ArrayExpr extends Expr {
557
635
  return this[FactorySymbol]({
558
636
  ast_type: "Builtin",
559
637
  type: this[TypeSymbol],
560
- location: get_location(2),
638
+ location: get_location(),
561
639
  builtin: "ArraySort",
562
640
  type_parameters: [this.value_type, projectedType],
563
641
  arguments: [this[AstSymbol], byExpr[AstSymbol]],
@@ -584,7 +662,7 @@ export class ArrayExpr extends Expr {
584
662
  return this[FactorySymbol]({
585
663
  ast_type: "Builtin",
586
664
  type: NullType,
587
- location: get_location(2),
665
+ location: get_location(),
588
666
  builtin: "ArrayReverseInPlace",
589
667
  type_parameters: [this.value_type],
590
668
  arguments: [this[AstSymbol]],
@@ -613,7 +691,7 @@ export class ArrayExpr extends Expr {
613
691
  return this[FactorySymbol]({
614
692
  ast_type: "Builtin",
615
693
  type: this[TypeSymbol],
616
- location: get_location(2),
694
+ location: get_location(),
617
695
  builtin: "ArrayReverse",
618
696
  type_parameters: [this.value_type],
619
697
  arguments: [this[AstSymbol]],
@@ -662,7 +740,7 @@ export class ArrayExpr extends Expr {
662
740
  return this[FactorySymbol]({
663
741
  ast_type: "Builtin",
664
742
  type: BooleanType,
665
- location: get_location(2),
743
+ location: get_location(),
666
744
  builtin: "ArrayIsSorted",
667
745
  type_parameters: [this.value_type, projectedType],
668
746
  arguments: [this[AstSymbol], byExpr[AstSymbol]],
@@ -719,7 +797,7 @@ export class ArrayExpr extends Expr {
719
797
  return this[FactorySymbol]({
720
798
  ast_type: "Builtin",
721
799
  type: IntegerType,
722
- location: get_location(2),
800
+ location: get_location(),
723
801
  builtin: "ArrayFindSortedFirst",
724
802
  type_parameters: [this.value_type, projectedType],
725
803
  arguments: [this[AstSymbol], valueAst, byExpr[AstSymbol]],
@@ -764,7 +842,7 @@ export class ArrayExpr extends Expr {
764
842
  return this[FactorySymbol]({
765
843
  ast_type: "Builtin",
766
844
  type: IntegerType,
767
- location: get_location(2),
845
+ location: get_location(),
768
846
  builtin: "ArrayFindSortedLast",
769
847
  type_parameters: [this.value_type, projectedType],
770
848
  arguments: [this[AstSymbol], valueAst, byExpr[AstSymbol]],
@@ -808,7 +886,7 @@ export class ArrayExpr extends Expr {
808
886
  return this[FactorySymbol]({
809
887
  ast_type: "Builtin",
810
888
  type: StructType({ start: IntegerType, end: IntegerType }),
811
- location: get_location(2),
889
+ location: get_location(),
812
890
  builtin: "ArrayFindSortedRange",
813
891
  type_parameters: [this.value_type, projectedType],
814
892
  arguments: [this[AstSymbol], valueAst, byExpr[AstSymbol]],
@@ -840,7 +918,7 @@ export class ArrayExpr extends Expr {
840
918
  return this[FactorySymbol]({
841
919
  ast_type: "Builtin",
842
920
  type: this[TypeSymbol],
843
- location: get_location(2),
921
+ location: get_location(),
844
922
  builtin: "ArraySlice",
845
923
  type_parameters: [this.value_type],
846
924
  arguments: [this[AstSymbol], startExpr[AstSymbol], endExpr[AstSymbol]],
@@ -869,7 +947,7 @@ export class ArrayExpr extends Expr {
869
947
  return this[FactorySymbol]({
870
948
  ast_type: "Builtin",
871
949
  type: this[TypeSymbol],
872
- location: get_location(2),
950
+ location: get_location(),
873
951
  builtin: "ArrayConcat",
874
952
  type_parameters: [this.value_type],
875
953
  arguments: [this[AstSymbol], otherExpr[AstSymbol]],
@@ -907,7 +985,7 @@ export class ArrayExpr extends Expr {
907
985
  const keysExpr = Expr.from(keys, ArrayType(IntegerType));
908
986
  let default_function_ast;
909
987
  if (onMissing === undefined) {
910
- const location = get_location(2);
988
+ const location = get_location();
911
989
  const default_function = Expr.function([IntegerType], this.value_type, ($, key) => $.error(Expr.str `Cannot get key ${key} from array`, location));
912
990
  default_function_ast = Expr.ast(default_function);
913
991
  }
@@ -918,7 +996,7 @@ export class ArrayExpr extends Expr {
918
996
  return this[FactorySymbol]({
919
997
  ast_type: "Builtin",
920
998
  type: this[TypeSymbol],
921
- location: get_location(2),
999
+ location: get_location(),
922
1000
  builtin: "ArrayGetKeys",
923
1001
  type_parameters: [this.value_type],
924
1002
  arguments: [this[AstSymbol], keysExpr[AstSymbol], default_function_ast],
@@ -953,7 +1031,7 @@ export class ArrayExpr extends Expr {
953
1031
  return this[FactorySymbol]({
954
1032
  ast_type: "Builtin",
955
1033
  type: NullType,
956
- location: get_location(2),
1034
+ location: get_location(),
957
1035
  builtin: "ArrayForEach",
958
1036
  type_parameters: [this.value_type, returnType],
959
1037
  arguments: [this[AstSymbol], fn[AstSymbol]],
@@ -984,7 +1062,7 @@ export class ArrayExpr extends Expr {
984
1062
  return this[FactorySymbol]({
985
1063
  ast_type: "Builtin",
986
1064
  type: this[TypeSymbol],
987
- location: get_location(2),
1065
+ location: get_location(),
988
1066
  builtin: "ArrayCopy",
989
1067
  type_parameters: [this.value_type],
990
1068
  arguments: [this[AstSymbol]],
@@ -1010,7 +1088,7 @@ export class ArrayExpr extends Expr {
1010
1088
  return this[FactorySymbol]({
1011
1089
  ast_type: "Builtin",
1012
1090
  type: ArrayType(output_type),
1013
- location: get_location(2),
1091
+ location: get_location(),
1014
1092
  builtin: "ArrayMap",
1015
1093
  type_parameters: [this.value_type, output_type],
1016
1094
  arguments: [this[AstSymbol], fn[AstSymbol]],
@@ -1082,7 +1160,7 @@ export class ArrayExpr extends Expr {
1082
1160
  }
1083
1161
  return this[FactorySymbol]({
1084
1162
  ast_type: "Builtin",
1085
- location: get_location(2),
1163
+ location: get_location(),
1086
1164
  type: this[TypeSymbol],
1087
1165
  builtin: "ArrayFilter",
1088
1166
  type_parameters: [this.value_type],
@@ -1106,7 +1184,7 @@ export class ArrayExpr extends Expr {
1106
1184
  return this[FactorySymbol]({
1107
1185
  ast_type: "Builtin",
1108
1186
  type: ArrayType(someType),
1109
- location: get_location(2),
1187
+ location: get_location(),
1110
1188
  builtin: "ArrayFilterMap",
1111
1189
  type_parameters: [this.value_type, someType],
1112
1190
  arguments: [this[AstSymbol], fnAst],
@@ -1125,7 +1203,7 @@ export class ArrayExpr extends Expr {
1125
1203
  return this[FactorySymbol]({
1126
1204
  ast_type: "Builtin",
1127
1205
  type: returnType,
1128
- location: get_location(2),
1206
+ location: get_location(),
1129
1207
  builtin: "ArrayFirstMap",
1130
1208
  type_parameters: [this.value_type, someType],
1131
1209
  arguments: [this[AstSymbol], fnAst],
@@ -1212,7 +1290,7 @@ export class ArrayExpr extends Expr {
1212
1290
  return this[FactorySymbol]({
1213
1291
  ast_type: "Builtin",
1214
1292
  type: returnType,
1215
- location: get_location(2),
1293
+ location: get_location(),
1216
1294
  builtin: "ArrayFold",
1217
1295
  type_parameters: [this.value_type, returnType],
1218
1296
  arguments: [this[AstSymbol], initAst, combineAst],
@@ -1225,7 +1303,7 @@ export class ArrayExpr extends Expr {
1225
1303
  return this[FactorySymbol]({
1226
1304
  ast_type: "Builtin",
1227
1305
  type: mapType,
1228
- location: get_location(2),
1306
+ location: get_location(),
1229
1307
  builtin: "ArrayMapReduce",
1230
1308
  type_parameters: [this.value_type, mapType],
1231
1309
  arguments: [this[AstSymbol], mapAst, combineAst],
@@ -1515,7 +1593,7 @@ export class ArrayExpr extends Expr {
1515
1593
  return this[FactorySymbol]({
1516
1594
  ast_type: "Builtin",
1517
1595
  type: StringType,
1518
- location: get_location(2),
1596
+ location: get_location(),
1519
1597
  builtin: "ArrayStringJoin",
1520
1598
  type_parameters: [],
1521
1599
  arguments: [this[AstSymbol], stringAst],
@@ -1527,7 +1605,7 @@ export class ArrayExpr extends Expr {
1527
1605
  return this[FactorySymbol]({
1528
1606
  ast_type: "Builtin",
1529
1607
  type: SetType(keyType),
1530
- location: get_location(2),
1608
+ location: get_location(),
1531
1609
  builtin: "ArrayToSet",
1532
1610
  type_parameters: [this.value_type, keyType],
1533
1611
  arguments: [this[AstSymbol], keyFnAst],
@@ -1540,7 +1618,7 @@ export class ArrayExpr extends Expr {
1540
1618
  const valueType = valueFnAst.type.output;
1541
1619
  let onConflictAst;
1542
1620
  if (onConflictFn === undefined) {
1543
- const location = get_location(2);
1621
+ const location = get_location();
1544
1622
  const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`, location));
1545
1623
  onConflictAst = Expr.ast(onConflictFunction);
1546
1624
  }
@@ -1550,7 +1628,7 @@ export class ArrayExpr extends Expr {
1550
1628
  return this[FactorySymbol]({
1551
1629
  ast_type: "Builtin",
1552
1630
  type: DictType(keyType, valueType),
1553
- location: get_location(2),
1631
+ location: get_location(),
1554
1632
  builtin: "ArrayToDict",
1555
1633
  type_parameters: [this.value_type, keyType, valueType],
1556
1634
  arguments: [this[AstSymbol], keyFnAst, valueFnAst, onConflictAst],
@@ -1566,7 +1644,7 @@ export class ArrayExpr extends Expr {
1566
1644
  return this[FactorySymbol]({
1567
1645
  ast_type: "Builtin",
1568
1646
  type: ArrayType(elementType),
1569
- location: get_location(2),
1647
+ location: get_location(),
1570
1648
  builtin: "ArrayFlattenToArray",
1571
1649
  type_parameters: [this.value_type, elementType],
1572
1650
  arguments: [this[AstSymbol], fnAst],
@@ -1582,7 +1660,7 @@ export class ArrayExpr extends Expr {
1582
1660
  return this[FactorySymbol]({
1583
1661
  ast_type: "Builtin",
1584
1662
  type: SetType(elementType),
1585
- location: get_location(2),
1663
+ location: get_location(),
1586
1664
  builtin: "ArrayFlattenToSet",
1587
1665
  type_parameters: [this.value_type, elementType],
1588
1666
  arguments: [this[AstSymbol], fnAst],
@@ -1598,7 +1676,7 @@ export class ArrayExpr extends Expr {
1598
1676
  const valueType = returnType.value;
1599
1677
  let onConflictAst;
1600
1678
  if (onConflictFn === undefined) {
1601
- const location = get_location(2);
1679
+ const location = get_location();
1602
1680
  const onConflictFunction = Expr.function([valueType, valueType, keyType], valueType, ($, existing, value, key) => $.error(Expr.str `Cannot insert duplicate key ${key} into dict`, location));
1603
1681
  onConflictAst = Expr.ast(onConflictFunction);
1604
1682
  }
@@ -1608,7 +1686,7 @@ export class ArrayExpr extends Expr {
1608
1686
  return this[FactorySymbol]({
1609
1687
  ast_type: "Builtin",
1610
1688
  type: DictType(keyType, valueType),
1611
- location: get_location(2),
1689
+ location: get_location(),
1612
1690
  builtin: "ArrayFlattenToDict",
1613
1691
  type_parameters: [this.value_type, keyType, valueType],
1614
1692
  arguments: [this[AstSymbol], fnAst, onConflictAst],
@@ -1624,7 +1702,7 @@ export class ArrayExpr extends Expr {
1624
1702
  return this[FactorySymbol]({
1625
1703
  ast_type: "Builtin",
1626
1704
  type: DictType(keyType, initType),
1627
- location: get_location(2),
1705
+ location: get_location(),
1628
1706
  builtin: "ArrayGroupFold",
1629
1707
  type_parameters: [this.value_type, keyType, initType],
1630
1708
  arguments: [this[AstSymbol], keyFnAst, initFnAst, reduceFnAst],
@@ -1801,5 +1879,87 @@ export class ArrayExpr extends Expr {
1801
1879
  }));
1802
1880
  }
1803
1881
  }
1882
+ /**
1883
+ * Encodes this array of structs as CSV data.
1884
+ *
1885
+ * @param options - CSV serialization options
1886
+ * @returns A BlobExpr containing the encoded CSV data
1887
+ *
1888
+ * @remarks Only works on arrays of structs with primitive or optional primitive fields.
1889
+ *
1890
+ * @example
1891
+ * ```ts
1892
+ * const PersonType = StructType({ name: StringType, age: IntegerType });
1893
+ *
1894
+ * const toCsv = East.function([ArrayType(PersonType)], BlobType, ($, people) => {
1895
+ * $.return(people.encodeCsv({ delimiter: ',' }));
1896
+ * });
1897
+ * const compiled = East.compile(toCsv.toIR(), []);
1898
+ * const blob = compiled([{ name: "Alice", age: 30n }, { name: "Bob", age: 25n }]);
1899
+ * new TextDecoder().decode(blob); // "name,age\r\nAlice,30\r\nBob,25"
1900
+ * ```
1901
+ */
1902
+ encodeCsv(options) {
1903
+ // Convert options to East config value
1904
+ const configValue = csvSerializeOptionsToValue(options);
1905
+ const configAst = valueOrExprToAstTyped(configValue, CsvSerializeConfigType);
1906
+ return this[FactorySymbol]({
1907
+ ast_type: "Builtin",
1908
+ type: BlobType,
1909
+ location: get_location(),
1910
+ builtin: "ArrayEncodeCsv",
1911
+ type_parameters: [this.value_type, CsvSerializeConfigType],
1912
+ arguments: [this[AstSymbol], configAst],
1913
+ });
1914
+ }
1915
+ /**
1916
+ * Checks if this array equals another array (deep comparison).
1917
+ *
1918
+ * @param other - The array to compare against
1919
+ * @returns A BooleanExpr that is true if the arrays are deeply equal
1920
+ *
1921
+ * @example
1922
+ * ```ts
1923
+ * const isEqual = East.function([ArrayType(IntegerType), ArrayType(IntegerType)], BooleanType, ($, a, b) => {
1924
+ * $.return(a.equals(b));
1925
+ * });
1926
+ * const compiled = East.compile(isEqual.toIR(), []);
1927
+ * compiled([1n, 2n, 3n], [1n, 2n, 3n]); // true
1928
+ * compiled([1n, 2n], [1n, 2n, 3n]); // false
1929
+ * ```
1930
+ */
1931
+ equals(other) {
1932
+ return equal(this, other);
1933
+ }
1934
+ /**
1935
+ * Checks if this array does not equal another array.
1936
+ *
1937
+ * @param other - The array to compare against
1938
+ * @returns A BooleanExpr that is true if the arrays are not equal
1939
+ *
1940
+ * @example
1941
+ * ```ts
1942
+ * const isNotEqual = East.function([ArrayType(IntegerType), ArrayType(IntegerType)], BooleanType, ($, a, b) => {
1943
+ * $.return(a.notEquals(b));
1944
+ * });
1945
+ * const compiled = East.compile(isNotEqual.toIR(), []);
1946
+ * compiled([1n, 2n], [1n, 2n, 3n]); // true
1947
+ * compiled([1n, 2n, 3n], [1n, 2n, 3n]); // false
1948
+ * ```
1949
+ */
1950
+ notEquals(other) {
1951
+ return notEqual(this, other);
1952
+ }
1953
+ // ============================================================================
1954
+ // Aliases for comparison operations
1955
+ // ============================================================================
1956
+ /** Alias for {@link equals} */
1957
+ eq = this.equals;
1958
+ /** Alias for {@link equals} */
1959
+ equal = this.equals;
1960
+ /** Alias for {@link notEquals} */
1961
+ ne = this.notEquals;
1962
+ /** Alias for {@link notEquals} */
1963
+ notEqual = this.notEquals;
1804
1964
  }
1805
1965
  //# sourceMappingURL=array.js.map