Fix RULES lossage
authorsimonpj@microsoft.com <unknown>
Sat, 22 Jul 2006 10:17:56 +0000 (10:17 +0000)
committersimonpj@microsoft.com <unknown>
Sat, 22 Jul 2006 10:17:56 +0000 (10:17 +0000)
commit4fbd341bca17fbe4af6dbe23ba414abc45729224
treea59be06a803fbe03b5bdbbb0670b36e94ee2ee9b
parente6d766e81c2c8fd0593778f9996103a65019189a
Fix RULES lossage

Don Stewart and Duncan Coutts encountered the following situation.
f = <rhs>
{-# RULES f ... #-}
where f is not exported, but appears in the inlinings of other
functions that are exported.  Then what happened was that the desugarer
produced this:
M.f = f
f = <rhs>
where the rules get attached to the M.f. But since M.f's RHS is trivial
(just f) it was unconditionally inlinined at all its call sites,
thereby losing the RULES attached to it.

This *is* a fragile aspect of rules. However this fix solves the
problem by instead generating
f = M.f
M.f = <rhs>

A pretty small chanage to the desugarer does the job.  It still feels
a little fragile, bt it's certainly more robust than before.
compiler/deSugar/DsBinds.lhs