Skip to content
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

Delay running %transform rules #3183

Open
2 tasks done
Z-snails opened this issue Jan 1, 2024 · 0 comments
Open
2 tasks done

Delay running %transform rules #3183

Z-snails opened this issue Jan 1, 2024 · 0 comments

Comments

@Z-snails
Copy link
Collaborator

Z-snails commented Jan 1, 2024

  • I have read CONTRIBUTING.md.
  • I have checked that there is no existing PR/issue about my proposal.

Summary

%transform rules should be run on CExp instead of Term, along with the other optimisations.

Motivation

Currently %transform rules are run on the core, rather than on CExp. This can make it fragile, since the lack eta-expansion and inlining can prevent rules from matching

The proposal

The %transform optimisation should be rewritten on CExp instead of Term. This might lead to more complexity, since CExp is more complex than Term, but it will make transform rules more reliable.

Examples

I have not managed to come up with a self-contained example yet, but while working on adding transform rules to prelude, I noticed the following fragility:

This definition allowed the rule to match:

Ord Nat where
    compare x y = compareNat x y

But this didnt:

Ord Nat where
    compare = compareNat

Technical implementation

N/A

Alternatives considered

Improve the current rewrite rule optimisation.
This may be complex, and will likely end up duplicating work, such as inlining and eta-expansion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant