Direct rewrite rules
- Langage dominant
- Haskell
- Étoiles
- 98
- Forks
- 17
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
At the moment rewrite rules have to specified using a pattern language. For example:
``` haskell
addCommutes = pat (BinOp Add "a" "b") := pat (BinOp Add "b" "a")
```
This rewrite rule could also be specified with a function:
``` haskell
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:
``` haskell
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!
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Évaluation
Cette issue n'a pas encore été évaluée.