Metatheory.jl
Metatheory.jl copied to clipboard
Issues in E-graph matching for parametrized types
Here is an example.
using Metatheory, TermInterface
struct Foo{A}
x::A
end
TermInterface.istree(::Foo{T}) where T = true
TermInterface.istree(::Type{Foo{T}}) where T = true
TermInterface.exprhead(::Foo) = :call
TermInterface.operation(::Foo{T}) where T = :(Foo{$T})
TermInterface.arguments(f::Foo) = f.x
function TermInterface.similarterm(::Type{Foo{T}}, f, args; metadata=nothing, exprhead = :call) where T
return Foo(args...)
end
t = @theory T A begin
Foo{T}(A) => A
end
f = Foo([:x])
eg = EGraph(f)
saturate!(eg, t)
extract!(eg, astsize) # this returns Foo([:x]) instead of [:x]