Fix Trac #2334: validity checking for type families
authorsimonpj@microsoft.com <unknown>
Fri, 6 Jun 2008 12:17:30 +0000 (12:17 +0000)
committersimonpj@microsoft.com <unknown>
Fri, 6 Jun 2008 12:17:30 +0000 (12:17 +0000)
commit1c05d4fbb6ee7ab68470d0aa79d74a3a4f0d8383
tree382a2b3599b9856326ea23a67d7c5a9a9aea6dc0
parent04d0ebc95aefb1e619be3078112b4d5c62a3a79f
Fix Trac #2334: validity checking for type families

When we deal with a family-instance declaration (TcTyClsDecls.tcFamInstDecl)
we must check the TyCon for validity; for example, that a newtype has exactly
one field.  That is done all-at-once for normal declarations, and had been
forgotten altogether for families.

I also refactored the interface to tcFamInstDecl1 slightly.

A slightly separate matter: if there's an error in family instances
(e.g. overlap) we get a confusing error message cascade if we attempt to
deal with 'deriving' clauses too; this patch bales out earlier in that case.

Another slightly separate matter: standalone deriving for family
instances can legitimately have more specific types, just like normal
data decls. For example

   data instance F [a] = ...
   deriving instance (Eq a, Eq b) => Eq (F [(a,b)])

So tcLookupFamInstExact can a bit more forgiving than it was.
compiler/typecheck/TcDeriv.lhs
compiler/typecheck/TcInstDcls.lhs
compiler/typecheck/TcTyClsDecls.lhs