[project @ 2002-01-29 09:58:14 by simonpj]
authorsimonpj <unknown>
Tue, 29 Jan 2002 09:58:21 +0000 (09:58 +0000)
committersimonpj <unknown>
Tue, 29 Jan 2002 09:58:21 +0000 (09:58 +0000)
commitf2054812b868d752c75dd0b148cc884b00f5e5d6
treed5113927c2624f2c9bd8fa3ed1cb0bf63760acd5
parenta704ee9c4180bf19a431e507f5d32a1f787c5c47
[project @ 2002-01-29 09:58:14 by simonpj]
------------
Rule phasing
------------

This commit adds a little more control to when rules are enabled.

  {-# RULES
       "foo" [2] forall ...
       "baz" [~2] forall ...
  #-}

Rule "foo" is active in phase 2 and later.  The new thing is that the
"~2" means that Rule "baz" is active in phase 3 and earlier.
(Remember tha phases decrease towards zero.)

All the machinery was there to implement this, it just needed the syntax.

Why do this?  Peter Gammie (at UNSW) found that rules weren't firing
because of bindings of the form

M.f = f
f = ....

where the rules where on the M.f binding.  It turned out that an old
hack (which have for some time elicited the harmless "shortMeOut" debug
warnings) prevented this trivial construction from being correctly
simplified.  The hack in turn derived from a trick in the way the
foldr/build rule was implemented....and that hack is no longer necessary
now we can switch rules *off* as well as *on*.

There are consequential changes in the Prelude foldr/build RULE stuff.
It's a clean-up.... Instead of strange definitions like
map = mapList
which we had before, we have an ordinary recursive defn of map, together
with rules to convert first to foldr/build form, and then (if nothing
happens) back again.

There's a fairly long comment about the general plan of attack in
PrelBase, near the defn of map.
ghc/compiler/basicTypes/BasicTypes.lhs
ghc/compiler/hsSyn/HsBinds.lhs
ghc/compiler/parser/Parser.y
ghc/compiler/prelude/PrelNames.lhs
ghc/compiler/prelude/PrelRules.lhs
ghc/compiler/rename/ParseIface.y
ghc/compiler/simplCore/OccurAnal.lhs
ghc/lib/std/PrelBase.lhs
ghc/lib/std/PrelEnum.lhs
ghc/lib/std/PrelList.lhs
ghc/lib/std/PrelNum.lhs