retrie icon indicating copy to clipboard operation
retrie copied to clipboard

Type applications break function matching

Open ilyakooo0 opened this issue 3 years ago • 3 comments

running the rule

forall a b. foo a b = foo b a

on the following file would succeed:

main = foo x y

while adding type applications to a function call would break matching the function and the rewrite would not be applied:

main = foo @Int x y

ilyakooo0 avatar Jun 26 '21 13:06 ilyakooo0

Matching is syntactic, so this is expected. Does the rule forall t a b. foo @t a b = foo @t b a work? (@ not strictly necessary, but would distinguish from a term-level variable)

I'm not sure how we could spot this is the general case since we don't have access to the type of foo (retrie only parses).

xich avatar Jun 27 '21 16:06 xich

No, it would not work. Type applications are not supported at all in rules. It will give an error.

ilyakooo0 avatar Jun 27 '21 17:06 ilyakooo0

I think ignoring type applications when matching would be far preferable to not matching at all. Right now if the codebase supports type applications, there is no reliable way of applying a rule to the codebase.

ilyakooo0 avatar Jun 27 '21 17:06 ilyakooo0