Remove the distinction between data and newtype families
[ghc-hetmet.git] / compiler / typecheck / TcDeriv.lhs
index 7a584cd..1a9a881 100644 (file)
@@ -381,6 +381,8 @@ deriveTyData (deriv_pred, L loc decl@(TyData { tcdLName = L _ tycon_name,
                -- The "deriv_pred" is a LHsType to take account of the fact that for
                -- newtype deriving we allow deriving (forall a. C [a]).
        ; mkEqnHelp DerivOrigin (tvs++deriv_tvs) cls cls_tys tc_app } }
+deriveTyData (deriv_pred, other_decl)
+  = panic "derivTyData"        -- Caller ensures that only TyData can happen
 
 ------------------------------------------------------------------
 mkEqnHelp orig tvs cls cls_tys tc_app
@@ -397,7 +399,10 @@ mkEqnHelp orig tvs cls cls_tys tc_app
 
        ; gla_exts <- doptM Opt_GlasgowExts
        ; overlap_flag <- getOverlapFlag
-       ; if isDataTyCon tycon then
+
+          -- Be careful to test rep_tc here: in the case of families, we want
+          -- to check the instance tycon, not the family tycon
+       ; if isDataTyCon rep_tc then
                mkDataTypeEqn orig gla_exts full_tvs cls cls_tys 
                              tycon full_tc_args rep_tc rep_tc_args
          else
@@ -541,7 +546,7 @@ cond_isProduct (gla_exts, rep_tc)
   | isProductTyCon rep_tc = Nothing
   | otherwise            = Just why
   where
-    why = (pprSourceTyCon rep_tc) <+> 
+    why = quotes (pprSourceTyCon rep_tc) <+> 
          ptext SLIT("has more than one constructor")
 
 cond_typeableOK :: Condition
@@ -576,7 +581,7 @@ std_class_via_iso clas      -- These standard classes can be derived for a newtype
 
 
 new_dfun_name clas tycon       -- Just a simple wrapper
-  = newDFunName clas [mkTyConApp tycon []] (getSrcLoc tycon)
+  = newDFunName clas [mkTyConApp tycon []] (getSrcSpan tycon)
        -- The type passed to newDFunName is only used to generate
        -- a suitable string; hence the empty type arg list
 \end{code}
@@ -1120,4 +1125,4 @@ badDerivedPred pred
          nest 2 (ptext SLIT("Offending constraint:") <+> ppr pred)]
 \end{code}
 
\ No newline at end of file