@@ -171,74 +171,3 @@ def _deconstruct_call_decl(
171
171
)
172
172
173
173
return RuntimeFunction (decls_thunk , Thunk .value (call .callable ), egg_bound ), arg_exprs
174
-
175
-
176
- ##
177
- # Alternative way of deconstructing expressions. Don't use this for now because type checking is harder for it.
178
- # is_expr_fn won't validate that the return types are the same b/c of type broadening and the above way is more succinct.
179
- ##
180
- # def deconstruct(x: T) -> tuple[Callable[..., T], Unpack[tuple[object, ...]]]:
181
- # """
182
- # Deconstructs a value into a callable and its arguments.
183
-
184
- # For all egglog expressions:
185
-
186
- # >>> fn, *args = deconstruct(expr)
187
- # >>> assert fn(*args) == expr
188
-
189
- # If the `expr` is a constant value (like from `const` or a classvar), then it will be wrapped in `DeconstructedConstant`
190
- # and return as the function with no arguments.
191
- # """
192
- # if not isinstance(x, RuntimeExpr):
193
- # raise TypeError(f"Expected Expression, got {type(x).__name__}")
194
-
195
- # match expr := x.__egg_typed_expr__.expr:
196
- # case UnboundVarDecl(name, egg_name):
197
- # tp = RuntimeClass(x.__egg_decls_thunk__, x.__egg_typed_expr__.tp.to_var())
198
- # return var, name, tp, egg_name
199
- # case LetRefDecl(name):
200
- # msg = "let expressions are not supported in deconstruct. Please open an issue if you need this feature."
201
- # raise NotImplementedError(msg)
202
- # case LitDecl(bool(b)):
203
- # return Bool, b
204
- # case LitDecl(int(i)):
205
- # return i64, i
206
- # case LitDecl(float(f)):
207
- # return f64, f
208
- # case LitDecl(None):
209
- # return (Unit,)
210
- # case PyObjectDecl(obj):
211
- # return PyObject, obj
212
- # case PartialCallDecl(call):
213
- # return UnstableFn, *_deconstruct_call_decl(x.__egg_decls_thunk__, call)
214
- # case CallDecl(callable):
215
- # if isinstance(callable, (ConstantRef, ClassVariableRef)):
216
- # return (DeconstructedConstant(x),)
217
- # return _deconstruct_call_decl(x.__egg_decls_thunk__, expr)
218
- # case _:
219
- # assert_never(expr)
220
-
221
-
222
- # @dataclass
223
- # class DeconstructedConstant(Generic[T]):
224
- # """
225
- # Wrapper around constant expressions retuen by `deconstruct`.
226
- # """
227
-
228
- # expr: T
229
-
230
- # def __call__(self) -> T:
231
- # """
232
- # Returns the constant expression.
233
- # """
234
- # return self.expr
235
-
236
-
237
- # def is_expr_fn(
238
- # deconstructed: tuple[Callable[..., T], Unpack[tuple[Any, ...]]],
239
- # fn: Callable[[Unpack[TS]], T],
240
- # ) -> TypeIs[tuple[Callable[[Unpack[TS]], T], Unpack[TS]]]:
241
- # """
242
- # Compares a deconstructed fn and args to a function, so that the args are now properly type cast.
243
- # """
244
- # return deconstructed[0] == fn
0 commit comments