Refactor, improve, and document the deriving mechanism
authorsimonpj@microsoft.com <unknown>
Wed, 5 Sep 2007 17:07:30 +0000 (17:07 +0000)
committersimonpj@microsoft.com <unknown>
Wed, 5 Sep 2007 17:07:30 +0000 (17:07 +0000)
commit25f84fa7e4b84c3db5ba745a7881c009b778e0b1
tree1b00125874ff77333b217b7a39c289e89e759951
parentd9236c265896d65ae4f1d4f4a240d8c0ffbce6f3
Refactor, improve, and document the deriving mechanism

This patch does a fairly major clean-up of the code that implements 'deriving.

* The big changes are in TcDeriv, which is dramatically cleaned up.
  In particular, there is a clear split into
a) inference of instance contexts for deriving clauses
b) generation of the derived code, given a context
  Step (a) is skipped for standalone instance decls, which
  have an explicitly provided context.

* The handling of "taggery", which is cooperative between TcDeriv and
  TcGenDeriv, is cleaned up a lot

* I have added documentation for standalone deriving (which was
  previously wrong).

* The Haskell report is vague on exactly when a deriving clause should
  succeed.  Prodded by Conal I have loosened the rules slightly, thereyb
  making drv015 work again, and documented the rules in the user manual.

I believe this patch validates ok (once I've update the test suite)
and can go into the 6.8 branch.
compiler/typecheck/TcDeriv.lhs
compiler/typecheck/TcEnv.lhs
compiler/typecheck/TcGenDeriv.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcMType.lhs
compiler/typecheck/TcSimplify.lhs
compiler/types/TyCon.lhs
compiler/types/Type.lhs
docs/users_guide/flags.xml
docs/users_guide/glasgow_exts.xml