egglog 6.0.0__cp312-none-win_amd64.whl → 6.1.0__cp312-none-win_amd64.whl

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.

Potentially problematic release.


This version of egglog might be problematic. Click here for more details.

egglog/builtins.py CHANGED
@@ -35,20 +35,17 @@ __all__ = [
35
35
 
36
36
 
37
37
  class String(Expr, builtin=True):
38
- def __init__(self, value: str) -> None:
39
- ...
38
+ def __init__(self, value: str) -> None: ...
40
39
 
41
40
  @method(egg_fn="replace")
42
- def replace(self, old: StringLike, new: StringLike) -> String:
43
- ...
41
+ def replace(self, old: StringLike, new: StringLike) -> String: ...
44
42
 
45
43
 
46
44
  StringLike: TypeAlias = String | str
47
45
 
48
46
 
49
47
  @function(egg_fn="+", builtin=True)
50
- def join(*strings: StringLike) -> String:
51
- ...
48
+ def join(*strings: StringLike) -> String: ...
52
49
 
53
50
 
54
51
  converter(str, String, String)
@@ -57,28 +54,22 @@ BoolLike = Union["Bool", bool]
57
54
 
58
55
 
59
56
  class Bool(Expr, egg_sort="bool", builtin=True):
60
- def __init__(self, value: bool) -> None:
61
- ...
57
+ def __init__(self, value: bool) -> None: ...
62
58
 
63
59
  @method(egg_fn="not")
64
- def __invert__(self) -> Bool:
65
- ...
60
+ def __invert__(self) -> Bool: ...
66
61
 
67
62
  @method(egg_fn="and")
68
- def __and__(self, other: BoolLike) -> Bool:
69
- ...
63
+ def __and__(self, other: BoolLike) -> Bool: ...
70
64
 
71
65
  @method(egg_fn="or")
72
- def __or__(self, other: BoolLike) -> Bool:
73
- ...
66
+ def __or__(self, other: BoolLike) -> Bool: ...
74
67
 
75
68
  @method(egg_fn="xor")
76
- def __xor__(self, other: BoolLike) -> Bool:
77
- ...
69
+ def __xor__(self, other: BoolLike) -> Bool: ...
78
70
 
79
71
  @method(egg_fn="=>")
80
- def implies(self, other: BoolLike) -> Bool:
81
- ...
72
+ def implies(self, other: BoolLike) -> Bool: ...
82
73
 
83
74
 
84
75
  converter(bool, Bool, Bool)
@@ -88,218 +79,167 @@ i64Like = Union["i64", int] # noqa: N816
88
79
 
89
80
 
90
81
  class i64(Expr, builtin=True): # noqa: N801
91
- def __init__(self, value: int) -> None:
92
- ...
82
+ def __init__(self, value: int) -> None: ...
93
83
 
94
84
  @method(egg_fn="+")
95
- def __add__(self, other: i64Like) -> i64:
96
- ...
85
+ def __add__(self, other: i64Like) -> i64: ...
97
86
 
98
87
  @method(egg_fn="-")
99
- def __sub__(self, other: i64Like) -> i64:
100
- ...
88
+ def __sub__(self, other: i64Like) -> i64: ...
101
89
 
102
90
  @method(egg_fn="*")
103
- def __mul__(self, other: i64Like) -> i64:
104
- ...
91
+ def __mul__(self, other: i64Like) -> i64: ...
105
92
 
106
93
  @method(egg_fn="/")
107
- def __truediv__(self, other: i64Like) -> i64:
108
- ...
94
+ def __truediv__(self, other: i64Like) -> i64: ...
109
95
 
110
96
  @method(egg_fn="%")
111
- def __mod__(self, other: i64Like) -> i64:
112
- ...
97
+ def __mod__(self, other: i64Like) -> i64: ...
113
98
 
114
99
  @method(egg_fn="&")
115
- def __and__(self, other: i64Like) -> i64:
116
- ...
100
+ def __and__(self, other: i64Like) -> i64: ...
117
101
 
118
102
  @method(egg_fn="|")
119
- def __or__(self, other: i64Like) -> i64:
120
- ...
103
+ def __or__(self, other: i64Like) -> i64: ...
121
104
 
122
105
  @method(egg_fn="^")
123
- def __xor__(self, other: i64Like) -> i64:
124
- ...
106
+ def __xor__(self, other: i64Like) -> i64: ...
125
107
 
126
108
  @method(egg_fn="<<")
127
- def __lshift__(self, other: i64Like) -> i64:
128
- ...
109
+ def __lshift__(self, other: i64Like) -> i64: ...
129
110
 
130
111
  @method(egg_fn=">>")
131
- def __rshift__(self, other: i64Like) -> i64:
132
- ...
112
+ def __rshift__(self, other: i64Like) -> i64: ...
133
113
 
134
- def __radd__(self, other: i64Like) -> i64:
135
- ...
114
+ def __radd__(self, other: i64Like) -> i64: ...
136
115
 
137
- def __rsub__(self, other: i64Like) -> i64:
138
- ...
116
+ def __rsub__(self, other: i64Like) -> i64: ...
139
117
 
140
- def __rmul__(self, other: i64Like) -> i64:
141
- ...
118
+ def __rmul__(self, other: i64Like) -> i64: ...
142
119
 
143
- def __rtruediv__(self, other: i64Like) -> i64:
144
- ...
120
+ def __rtruediv__(self, other: i64Like) -> i64: ...
145
121
 
146
- def __rmod__(self, other: i64Like) -> i64:
147
- ...
122
+ def __rmod__(self, other: i64Like) -> i64: ...
148
123
 
149
- def __rand__(self, other: i64Like) -> i64:
150
- ...
124
+ def __rand__(self, other: i64Like) -> i64: ...
151
125
 
152
- def __ror__(self, other: i64Like) -> i64:
153
- ...
126
+ def __ror__(self, other: i64Like) -> i64: ...
154
127
 
155
- def __rxor__(self, other: i64Like) -> i64:
156
- ...
128
+ def __rxor__(self, other: i64Like) -> i64: ...
157
129
 
158
- def __rlshift__(self, other: i64Like) -> i64:
159
- ...
130
+ def __rlshift__(self, other: i64Like) -> i64: ...
160
131
 
161
- def __rrshift__(self, other: i64Like) -> i64:
162
- ...
132
+ def __rrshift__(self, other: i64Like) -> i64: ...
163
133
 
164
134
  @method(egg_fn="not-i64")
165
- def __invert__(self) -> i64:
166
- ...
135
+ def __invert__(self) -> i64: ...
167
136
 
168
137
  @method(egg_fn="<")
169
138
  def __lt__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type]
170
139
  ...
171
140
 
172
141
  @method(egg_fn=">")
173
- def __gt__(self, other: i64Like) -> Unit:
174
- ...
142
+ def __gt__(self, other: i64Like) -> Unit: ...
175
143
 
176
144
  @method(egg_fn="<=")
177
145
  def __le__(self, other: i64Like) -> Unit: # type: ignore[empty-body,has-type]
178
146
  ...
179
147
 
180
148
  @method(egg_fn=">=")
181
- def __ge__(self, other: i64Like) -> Unit:
182
- ...
149
+ def __ge__(self, other: i64Like) -> Unit: ...
183
150
 
184
151
  @method(egg_fn="min")
185
- def min(self, other: i64Like) -> i64:
186
- ...
152
+ def min(self, other: i64Like) -> i64: ...
187
153
 
188
154
  @method(egg_fn="max")
189
- def max(self, other: i64Like) -> i64:
190
- ...
155
+ def max(self, other: i64Like) -> i64: ...
191
156
 
192
157
  @method(egg_fn="to-string")
193
- def to_string(self) -> String:
194
- ...
158
+ def to_string(self) -> String: ...
195
159
 
196
160
  @method(egg_fn="bool-<")
197
- def bool_lt(self, other: i64Like) -> Bool:
198
- ...
161
+ def bool_lt(self, other: i64Like) -> Bool: ...
199
162
 
200
163
  @method(egg_fn="bool->")
201
- def bool_gt(self, other: i64Like) -> Bool:
202
- ...
164
+ def bool_gt(self, other: i64Like) -> Bool: ...
203
165
 
204
166
  @method(egg_fn="bool-<=")
205
- def bool_le(self, other: i64Like) -> Bool:
206
- ...
167
+ def bool_le(self, other: i64Like) -> Bool: ...
207
168
 
208
169
  @method(egg_fn="bool->=")
209
- def bool_ge(self, other: i64Like) -> Bool:
210
- ...
170
+ def bool_ge(self, other: i64Like) -> Bool: ...
211
171
 
212
172
 
213
173
  converter(int, i64, i64)
214
174
 
215
175
 
216
176
  @function(builtin=True, egg_fn="count-matches")
217
- def count_matches(s: StringLike, pattern: StringLike) -> i64:
218
- ...
177
+ def count_matches(s: StringLike, pattern: StringLike) -> i64: ...
219
178
 
220
179
 
221
180
  f64Like = Union["f64", float] # noqa: N816
222
181
 
223
182
 
224
183
  class f64(Expr, builtin=True): # noqa: N801
225
- def __init__(self, value: float) -> None:
226
- ...
184
+ def __init__(self, value: float) -> None: ...
227
185
 
228
186
  @method(egg_fn="neg")
229
- def __neg__(self) -> f64:
230
- ...
187
+ def __neg__(self) -> f64: ...
231
188
 
232
189
  @method(egg_fn="+")
233
- def __add__(self, other: f64Like) -> f64:
234
- ...
190
+ def __add__(self, other: f64Like) -> f64: ...
235
191
 
236
192
  @method(egg_fn="-")
237
- def __sub__(self, other: f64Like) -> f64:
238
- ...
193
+ def __sub__(self, other: f64Like) -> f64: ...
239
194
 
240
195
  @method(egg_fn="*")
241
- def __mul__(self, other: f64Like) -> f64:
242
- ...
196
+ def __mul__(self, other: f64Like) -> f64: ...
243
197
 
244
198
  @method(egg_fn="/")
245
- def __truediv__(self, other: f64Like) -> f64:
246
- ...
199
+ def __truediv__(self, other: f64Like) -> f64: ...
247
200
 
248
201
  @method(egg_fn="%")
249
- def __mod__(self, other: f64Like) -> f64:
250
- ...
202
+ def __mod__(self, other: f64Like) -> f64: ...
251
203
 
252
- def __radd__(self, other: f64Like) -> f64:
253
- ...
204
+ def __radd__(self, other: f64Like) -> f64: ...
254
205
 
255
- def __rsub__(self, other: f64Like) -> f64:
256
- ...
206
+ def __rsub__(self, other: f64Like) -> f64: ...
257
207
 
258
- def __rmul__(self, other: f64Like) -> f64:
259
- ...
208
+ def __rmul__(self, other: f64Like) -> f64: ...
260
209
 
261
- def __rtruediv__(self, other: f64Like) -> f64:
262
- ...
210
+ def __rtruediv__(self, other: f64Like) -> f64: ...
263
211
 
264
- def __rmod__(self, other: f64Like) -> f64:
265
- ...
212
+ def __rmod__(self, other: f64Like) -> f64: ...
266
213
 
267
214
  @method(egg_fn="<")
268
215
  def __lt__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type]
269
216
  ...
270
217
 
271
218
  @method(egg_fn=">")
272
- def __gt__(self, other: f64Like) -> Unit:
273
- ...
219
+ def __gt__(self, other: f64Like) -> Unit: ...
274
220
 
275
221
  @method(egg_fn="<=")
276
222
  def __le__(self, other: f64Like) -> Unit: # type: ignore[empty-body,has-type]
277
223
  ...
278
224
 
279
225
  @method(egg_fn=">=")
280
- def __ge__(self, other: f64Like) -> Unit:
281
- ...
226
+ def __ge__(self, other: f64Like) -> Unit: ...
282
227
 
283
228
  @method(egg_fn="min")
284
- def min(self, other: f64Like) -> f64:
285
- ...
229
+ def min(self, other: f64Like) -> f64: ...
286
230
 
287
231
  @method(egg_fn="max")
288
- def max(self, other: f64Like) -> f64:
289
- ...
232
+ def max(self, other: f64Like) -> f64: ...
290
233
 
291
234
  @method(egg_fn="to-i64")
292
- def to_i64(self) -> i64:
293
- ...
235
+ def to_i64(self) -> i64: ...
294
236
 
295
237
  @method(egg_fn="to-f64")
296
238
  @classmethod
297
- def from_i64(cls, i: i64) -> f64:
298
- ...
239
+ def from_i64(cls, i: i64) -> f64: ...
299
240
 
300
241
  @method(egg_fn="to-string")
301
- def to_string(self) -> String:
302
- ...
242
+ def to_string(self) -> String: ...
303
243
 
304
244
 
305
245
  converter(float, f64, f64)
@@ -312,243 +252,188 @@ V = TypeVar("V", bound=Expr)
312
252
  class Map(Expr, Generic[T, V], builtin=True):
313
253
  @method(egg_fn="map-empty")
314
254
  @classmethod
315
- def empty(cls) -> Map[T, V]:
316
- ...
255
+ def empty(cls) -> Map[T, V]: ...
317
256
 
318
257
  @method(egg_fn="map-insert")
319
- def insert(self, key: T, value: V) -> Map[T, V]:
320
- ...
258
+ def insert(self, key: T, value: V) -> Map[T, V]: ...
321
259
 
322
260
  @method(egg_fn="map-get")
323
- def __getitem__(self, key: T) -> V:
324
- ...
261
+ def __getitem__(self, key: T) -> V: ...
325
262
 
326
263
  @method(egg_fn="map-not-contains")
327
- def not_contains(self, key: T) -> Unit:
328
- ...
264
+ def not_contains(self, key: T) -> Unit: ...
329
265
 
330
266
  @method(egg_fn="map-contains")
331
- def contains(self, key: T) -> Unit:
332
- ...
267
+ def contains(self, key: T) -> Unit: ...
333
268
 
334
269
  @method(egg_fn="map-remove")
335
- def remove(self, key: T) -> Map[T, V]:
336
- ...
270
+ def remove(self, key: T) -> Map[T, V]: ...
337
271
 
338
272
  @method(egg_fn="rebuild")
339
- def rebuild(self) -> Map[T, V]:
340
- ...
273
+ def rebuild(self) -> Map[T, V]: ...
341
274
 
342
275
 
343
276
  class Set(Expr, Generic[T], builtin=True):
344
277
  @method(egg_fn="set-of")
345
- def __init__(self, *args: T) -> None:
346
- ...
278
+ def __init__(self, *args: T) -> None: ...
347
279
 
348
280
  @method(egg_fn="set-empty")
349
281
  @classmethod
350
- def empty(cls) -> Set[T]:
351
- ...
282
+ def empty(cls) -> Set[T]: ...
352
283
 
353
284
  @method(egg_fn="set-insert")
354
- def insert(self, value: T) -> Set[T]:
355
- ...
285
+ def insert(self, value: T) -> Set[T]: ...
356
286
 
357
287
  @method(egg_fn="set-not-contains")
358
- def not_contains(self, value: T) -> Unit:
359
- ...
288
+ def not_contains(self, value: T) -> Unit: ...
360
289
 
361
290
  @method(egg_fn="set-contains")
362
- def contains(self, value: T) -> Unit:
363
- ...
291
+ def contains(self, value: T) -> Unit: ...
364
292
 
365
293
  @method(egg_fn="set-remove")
366
- def remove(self, value: T) -> Set[T]:
367
- ...
294
+ def remove(self, value: T) -> Set[T]: ...
368
295
 
369
296
  @method(egg_fn="set-union")
370
- def __or__(self, other: Set[T]) -> Set[T]:
371
- ...
297
+ def __or__(self, other: Set[T]) -> Set[T]: ...
372
298
 
373
299
  @method(egg_fn="set-diff")
374
- def __sub__(self, other: Set[T]) -> Set[T]:
375
- ...
300
+ def __sub__(self, other: Set[T]) -> Set[T]: ...
376
301
 
377
302
  @method(egg_fn="set-intersect")
378
- def __and__(self, other: Set[T]) -> Set[T]:
379
- ...
303
+ def __and__(self, other: Set[T]) -> Set[T]: ...
380
304
 
381
305
  @method(egg_fn="rebuild")
382
- def rebuild(self) -> Set[T]:
383
- ...
306
+ def rebuild(self) -> Set[T]: ...
384
307
 
385
308
 
386
309
  class Rational(Expr, builtin=True):
387
310
  @method(egg_fn="rational")
388
- def __init__(self, num: i64Like, den: i64Like) -> None:
389
- ...
311
+ def __init__(self, num: i64Like, den: i64Like) -> None: ...
390
312
 
391
313
  @method(egg_fn="to-f64")
392
- def to_f64(self) -> f64:
393
- ...
314
+ def to_f64(self) -> f64: ...
394
315
 
395
316
  @method(egg_fn="+")
396
- def __add__(self, other: Rational) -> Rational:
397
- ...
317
+ def __add__(self, other: Rational) -> Rational: ...
398
318
 
399
319
  @method(egg_fn="-")
400
- def __sub__(self, other: Rational) -> Rational:
401
- ...
320
+ def __sub__(self, other: Rational) -> Rational: ...
402
321
 
403
322
  @method(egg_fn="*")
404
- def __mul__(self, other: Rational) -> Rational:
405
- ...
323
+ def __mul__(self, other: Rational) -> Rational: ...
406
324
 
407
325
  @method(egg_fn="/")
408
- def __truediv__(self, other: Rational) -> Rational:
409
- ...
326
+ def __truediv__(self, other: Rational) -> Rational: ...
410
327
 
411
328
  @method(egg_fn="min")
412
- def min(self, other: Rational) -> Rational:
413
- ...
329
+ def min(self, other: Rational) -> Rational: ...
414
330
 
415
331
  @method(egg_fn="max")
416
- def max(self, other: Rational) -> Rational:
417
- ...
332
+ def max(self, other: Rational) -> Rational: ...
418
333
 
419
334
  @method(egg_fn="neg")
420
- def __neg__(self) -> Rational:
421
- ...
335
+ def __neg__(self) -> Rational: ...
422
336
 
423
337
  @method(egg_fn="abs")
424
- def __abs__(self) -> Rational:
425
- ...
338
+ def __abs__(self) -> Rational: ...
426
339
 
427
340
  @method(egg_fn="floor")
428
- def floor(self) -> Rational:
429
- ...
341
+ def floor(self) -> Rational: ...
430
342
 
431
343
  @method(egg_fn="ceil")
432
- def ceil(self) -> Rational:
433
- ...
344
+ def ceil(self) -> Rational: ...
434
345
 
435
346
  @method(egg_fn="round")
436
- def round(self) -> Rational:
437
- ...
347
+ def round(self) -> Rational: ...
438
348
 
439
349
  @method(egg_fn="pow")
440
- def __pow__(self, other: Rational) -> Rational:
441
- ...
350
+ def __pow__(self, other: Rational) -> Rational: ...
442
351
 
443
352
  @method(egg_fn="log")
444
- def log(self) -> Rational:
445
- ...
353
+ def log(self) -> Rational: ...
446
354
 
447
355
  @method(egg_fn="sqrt")
448
- def sqrt(self) -> Rational:
449
- ...
356
+ def sqrt(self) -> Rational: ...
450
357
 
451
358
  @method(egg_fn="cbrt")
452
- def cbrt(self) -> Rational:
453
- ...
359
+ def cbrt(self) -> Rational: ...
454
360
 
455
361
  @method(egg_fn="numer") # type: ignore[misc]
456
362
  @property
457
- def numer(self) -> i64:
458
- ...
363
+ def numer(self) -> i64: ...
459
364
 
460
365
  @method(egg_fn="denom") # type: ignore[misc]
461
366
  @property
462
- def denom(self) -> i64:
463
- ...
367
+ def denom(self) -> i64: ...
464
368
 
465
369
 
466
370
  class Vec(Expr, Generic[T], builtin=True):
467
371
  @method(egg_fn="vec-of")
468
- def __init__(self, *args: T) -> None:
469
- ...
372
+ def __init__(self, *args: T) -> None: ...
470
373
 
471
374
  @method(egg_fn="vec-empty")
472
375
  @classmethod
473
- def empty(cls) -> Vec[T]:
474
- ...
376
+ def empty(cls) -> Vec[T]: ...
475
377
 
476
378
  @method(egg_fn="vec-append")
477
- def append(self, *others: Vec[T]) -> Vec[T]:
478
- ...
379
+ def append(self, *others: Vec[T]) -> Vec[T]: ...
479
380
 
480
381
  @method(egg_fn="vec-push")
481
- def push(self, value: T) -> Vec[T]:
482
- ...
382
+ def push(self, value: T) -> Vec[T]: ...
483
383
 
484
384
  @method(egg_fn="vec-pop")
485
- def pop(self) -> Vec[T]:
486
- ...
385
+ def pop(self) -> Vec[T]: ...
487
386
 
488
387
  @method(egg_fn="vec-not-contains")
489
- def not_contains(self, value: T) -> Unit:
490
- ...
388
+ def not_contains(self, value: T) -> Unit: ...
491
389
 
492
390
  @method(egg_fn="vec-contains")
493
- def contains(self, value: T) -> Unit:
494
- ...
391
+ def contains(self, value: T) -> Unit: ...
495
392
 
496
393
  @method(egg_fn="vec-length")
497
- def length(self) -> i64:
498
- ...
394
+ def length(self) -> i64: ...
499
395
 
500
396
  @method(egg_fn="vec-get")
501
- def __getitem__(self, index: i64Like) -> T:
502
- ...
397
+ def __getitem__(self, index: i64Like) -> T: ...
503
398
 
504
399
  @method(egg_fn="rebuild")
505
- def rebuild(self) -> Vec[T]:
506
- ...
400
+ def rebuild(self) -> Vec[T]: ...
507
401
 
508
402
 
509
403
  class PyObject(Expr, builtin=True):
510
- def __init__(self, value: object) -> None:
511
- ...
404
+ def __init__(self, value: object) -> None: ...
512
405
 
513
406
  @method(egg_fn="py-from-string")
514
407
  @classmethod
515
- def from_string(cls, s: StringLike) -> PyObject:
516
- ...
408
+ def from_string(cls, s: StringLike) -> PyObject: ...
517
409
 
518
410
  @method(egg_fn="py-to-string")
519
- def to_string(self) -> String:
520
- ...
411
+ def to_string(self) -> String: ...
521
412
 
522
413
  @method(egg_fn="py-to-bool")
523
- def to_bool(self) -> Bool:
524
- ...
414
+ def to_bool(self) -> Bool: ...
525
415
 
526
416
  @method(egg_fn="py-dict-update")
527
- def dict_update(self, *keys_and_values: object) -> PyObject:
528
- ...
417
+ def dict_update(self, *keys_and_values: object) -> PyObject: ...
529
418
 
530
419
  @method(egg_fn="py-from-int")
531
420
  @classmethod
532
- def from_int(cls, i: i64Like) -> PyObject:
533
- ...
421
+ def from_int(cls, i: i64Like) -> PyObject: ...
534
422
 
535
423
  @method(egg_fn="py-dict")
536
424
  @classmethod
537
- def dict(cls, *keys_and_values: object) -> PyObject:
538
- ...
425
+ def dict(cls, *keys_and_values: object) -> PyObject: ...
539
426
 
540
427
 
541
428
  converter(object, PyObject, PyObject)
542
429
 
543
430
 
544
431
  @function(builtin=True, egg_fn="py-eval")
545
- def py_eval(code: StringLike, globals: object = PyObject.dict(), locals: object = PyObject.dict()) -> PyObject:
546
- ...
432
+ def py_eval(code: StringLike, globals: object = PyObject.dict(), locals: object = PyObject.dict()) -> PyObject: ...
547
433
 
548
434
 
549
435
  class PyObjectFunction(Protocol):
550
- def __call__(self, *__args: PyObject) -> PyObject:
551
- ...
436
+ def __call__(self, *__args: PyObject) -> PyObject: ...
552
437
 
553
438
 
554
439
  def py_eval_fn(fn: Callable) -> PyObjectFunction:
@@ -563,8 +448,7 @@ def py_eval_fn(fn: Callable) -> PyObjectFunction:
563
448
  new_kvs: list[object] = []
564
449
  eval_str = "__fn("
565
450
  for i, arg in enumerate(__args):
566
- new_kvs.append(f"__arg_{i}")
567
- new_kvs.append(arg)
451
+ new_kvs.extend((f"__arg_{i}", arg))
568
452
  eval_str += f"__arg_{i}, "
569
453
  eval_str += ")"
570
454
  return py_eval(eval_str, PyObject({"__fn": __fn}).dict_update(*new_kvs), __fn.__globals__)
egglog/declarations.py CHANGED
@@ -103,8 +103,7 @@ UNARY_METHODS = {
103
103
  @runtime_checkable
104
104
  class HasDeclerations(Protocol):
105
105
  @property
106
- def __egg_decls__(self) -> Declarations:
107
- ...
106
+ def __egg_decls__(self) -> Declarations: ...
108
107
 
109
108
 
110
109
  DeclerationsLike: TypeAlias = Union[HasDeclerations, None, "Declarations"]
@@ -1000,6 +999,16 @@ class TypedExprDecl:
1000
999
  def to_egg(self, decls: Declarations) -> bindings._Expr:
1001
1000
  return self.expr.to_egg(decls)
1002
1001
 
1002
+ def descendants(self) -> list[TypedExprDecl]:
1003
+ """
1004
+ Returns a list of all the descendants of this expression.
1005
+ """
1006
+ l = [self]
1007
+ if isinstance(self.expr, CallDecl):
1008
+ for a in self.expr.args:
1009
+ l.extend(a.descendants())
1010
+ return l
1011
+
1003
1012
 
1004
1013
  @dataclass
1005
1014
  class ClassDecl: