Metatheory.jl
Metatheory.jl copied to clipboard
is this the best way to `reverse(r::Rule)`?
I haven't really read through this repo, but I didn't see an easy way to take @rule ~x => exp(~x) to @rule exp(~x) => ~x.
This was the hack I came up with
myreverse(r::Metatheory.Rules.AbstractRule) = myreverse(r.expr)
function myreverse(rex)
args = rex.args
newex = Expr(:call, args[[1, 3, 2]]...)
eval(:(@rule $newex))
end
it seems to work fine but it might be a bad way of doing it
Hi anand. This is possible and fairly easy. I can add a function overloading Base.inv, but you have to know that inverting a rule that has more variables on the lhs. than the rhs will result in an error. (e.g., @rule f(~x, ~y, ~z) => g(~x) is not invertible)