Several fixes to 'deriving' including Trac #2378
authorsimonpj@microsoft.com <unknown>
Tue, 1 Jul 2008 12:09:08 +0000 (12:09 +0000)
committersimonpj@microsoft.com <unknown>
Tue, 1 Jul 2008 12:09:08 +0000 (12:09 +0000)
commit9319fbaf14f420cbbd9e670093cc86c5f04b7800
treefdd0ee9769f8da04a1686bd2fbdd7746069df9ec
parentcb906a124e36cb5054784a5bc44eb9d099d20709
Several fixes to 'deriving' including Trac #2378

This patch collects several related things together.

* Refactor TcDeriv so that the InstInfo and the method bindings are renamed
  together.  This was messy before, and is cleaner now.  Fixes a bug caused
  by interaction between the "auxiliary bindings" (which were given
  Original names before), and stand-alone deriving (which meant that those
  Original names came from a different module). Now the names are purely
  local an ordinary.

  To do this, InstInfo is parameterised like much else HsSyn stuff.

* Improve the location info in a dfun, which in turn improves location
  info for error messages, e.g. overlapping instances

* Make sure that newtype-deriving isn't used for Typeable1 and friends.
  (Typeable was rightly taken care of, but not Typeable1,2, etc.)

* Check for data types in deriving Data, so that you can't do, say,
  deriving instance Data (IO a)

* Decorate the derived binding with location info from the *instance*
  rather than from the *tycon*.  Again, this really only matters with
  standalone deriving, but it makes a huge difference there.

I think that's it.  Quite a few error messages change slightly.

If we release 6.8.4, this should go in if possible.
compiler/typecheck/TcClassDcl.lhs
compiler/typecheck/TcDeriv.lhs
compiler/typecheck/TcEnv.lhs
compiler/typecheck/TcGenDeriv.lhs
compiler/typecheck/TcHsType.lhs
compiler/typecheck/TcInstDcls.lhs