Does GHC simplify RULES?

Simon Peyton-Jones
Mon, 25 Feb 2002 00:27:09 -0800

| Suppose I have the following RULES pragma:
| {-# RULES
|   "foo" forall a . foo a =3D (\x -> bar x) a
| #-}
| Ok, it's stupid but I have examples where this is motivated, trust me.
| Now, it seems that GHC simplifies the rule because what I get=20
| when compiling it with -ddump-rules is the following rule:
| "foo" __forall {@ t_a2UD a :: t_a2UD}
| @ t_a2UD a
| 	=3D @ t_a2UD a ;
| It's \beta-reduced! Argh! Why is that?

Because if it's left unsimplified, the first thing that will happen
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.