Does GHC simplify RULES?
Simon Peyton-Jones
simonpj@microsoft.com
Mon, 25 Feb 2002 00:27:09 -0800
| Suppose I have the following RULES pragma:
|=20
| {-# RULES
| "foo" forall a . foo a =3D (\x -> bar x) a
| #-}
|=20
| Ok, it's stupid but I have examples where this is motivated, trust me.
|=20
| Now, it seems that GHC simplifies the rule because what I get=20
| when compiling it with -ddump-rules is the following rule:
|=20
| "foo" __forall {@ t_a2UD a :: t_a2UD}
| Test.foo @ t_a2UD a
| =3D Test.bar @ t_a2UD a ;
|=20
| It's \beta-reduced! Argh! Why is that?
Because if it's left unsimplified, the first thing that will happen
after
the rule fires is that the beta reduction will be done. So why not
do it first? (The desugarer can leave quite a lot of crud around,
so a gentle simplification is indeed run.)
You'll need to explain your motivation a bit more. Perhaps give
the rules you'd like along with a sample simplification sequence.
Simon