Big tidy-up of deriving code
authorsimonpj@microsoft.com <unknown>
Tue, 2 Jan 2007 15:46:10 +0000 (15:46 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 2 Jan 2007 15:46:10 +0000 (15:46 +0000)
commit84923cc7de2a93c22a2f72daf9ac863959efae13
tree723983c2828e1897319bedbeb6ab69608d911a72
parent3ded6e65b730c2b5eb9a9519448bbcd905c5d7fa
Big tidy-up of deriving code

This tidy-up, triggered by Trac #1068, re-factors the way that 'deriving'
happens.  It took me way longer than I had intended.  The main changes,
by far are to TcDeriv; everyting else is a minor consequence.

While I was at it, I changed the syntax for standalone deriving, so that
it goes
derive instance Show (T a)

(instead of "derive Show for T").  However, there's still an implicit
context, generated by the deriving code, and I wonder if it shouldn't really
be
derive instance (..) => Show (T a)
but I have left it simple for now.

I also added a function Type.substTyVars, and used it here and there, which
led to some one-line changes otherwise unrelated (sorry).

Loose ends:
  * 'deriving Typeable' for indexed data types is still not right
  * standalone deriving should be documented
22 files changed:
compiler/basicTypes/DataCon.lhs
compiler/basicTypes/MkId.lhs
compiler/hsSyn/HsDecls.lhs
compiler/hsSyn/HsTypes.lhs
compiler/hsSyn/HsUtils.lhs
compiler/parser/Lexer.x
compiler/parser/Parser.y.pp
compiler/rename/RnSource.lhs
compiler/typecheck/Inst.lhs
compiler/typecheck/TcDeriv.lhs
compiler/typecheck/TcEnv.lhs
compiler/typecheck/TcExpr.lhs
compiler/typecheck/TcGenDeriv.lhs
compiler/typecheck/TcHsType.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcMType.lhs
compiler/typecheck/TcSimplify.lhs
compiler/typecheck/TcType.lhs
compiler/types/FamInstEnv.lhs
compiler/types/TyCon.lhs
compiler/types/Type.lhs
compiler/utils/Util.lhs