At the moment rewrite rules have to specified using a pattern language. For example:
addCommutes = pat (BinOp Add "a" "b") := pat (BinOp Add "b" "a")
This rewrite rule could also be specified with a function:
addCommutes = \case
Fix (BinOp Add a b) -> Just (Fix (BinOp Add b a))
_ -> Nothing
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:
data F a = Foo Int a | ...
and you want to match Foo n x only when n satisfies some property, and use n to rewrite the term in some non-trivial way.
And thanks for the great package!
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 xonly whennsatisfies some property, and usento rewrite the term in some non-trivial way.And thanks for the great package!