-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Direct rewrite rules #29
Comments
Interesting idea! I think it would be lovely to be able to write "direct" rewrite rules as you've presented them. I can't tell right away whether it's possible, but we might be able to pull it off. In essence, equality saturation works by
The e-matching's is done through the
So the (Small aside on conditional rewrite rule, which come from section 4.2 of the egg paper: I don't think they are sufficient to implement the kind of conditional matching you want, as they seem to be conditions based on analysis data of the variable parts of the pattern. In that sense, what you envision seems more appropriate and much more direct) It is probably best to keep the e-matching main work function as is - receiving a pattern. Ideally, we should be able to go back and forth between those two implementations as they seem roughly equivalent... We should probably start from the "direct" rewrite rule and try to reconstruct the pattern based one. I'll have more time to investigate this in October, but I'll be happy to participate in a discussion if you decide to pursue this line of thought. Thanks! |
Yes, this is what led me to the question: the direct approach allows much more control.
I have only very vaguely looked at the code and papers you linked, but I'm not sure this is the right approach, I think the direct approach likely has significant disadvantages (it can't efficiently express non-linear patterns for example), so you wouldn't want to build on it, I was thinking of it more as an escape hatch. |
Minor note: Currently languages are grouped by One approach I like is to separate matching and rewriting. Here with OverloadedRecordDot for some sugar:
This is basically data Subst f = S (f Subst) | C ClassId This is pretty powerful:
|
At the moment rewrite rules have to specified using a pattern language. For example:
This rewrite rule could also be specified with a function:
I'll refer to this as a "direct" rewrite rule.
I imagine there are advantages to the pattern matching approach, but I was wondering if it would also be possible to specify rewrite rules using the "direct" approach too? The sort of situation I would like to handle is for example when your language functor has a case like:
and you want to match
Foo n x
only whenn
satisfies some property, and usen
to rewrite the term in some non-trivial way.And thanks for the great package!
The text was updated successfully, but these errors were encountered: