Fix and improve deriving for indexed data types
[ghc-hetmet.git] / compiler / typecheck / TcInstDcls.lhs
index 0be7724..da18ef1 100644 (file)
@@ -240,11 +240,7 @@ tcLocalInstDecl1 decl@(L loc (InstDecl poly_ty binds uprags ats))
        ; checkTc (not is_boot || (isEmptyLHsBinds binds && null uprags))
                  badBootDeclErr
 
-       -- Typecheck the instance type itself.  We can't use 
-       -- tcHsSigType, because it's not a valid user type.
-       ; kinded_ty <- kcHsSigType poly_ty
-       ; poly_ty'  <- tcHsKindedType kinded_ty
-       ; let (tyvars, theta, tau) = tcSplitSigmaTy poly_ty'
+       ; (tyvars, theta, tau) <- tcHsInstHead poly_ty
        
        -- Next, process any associated types.
        ; idx_tycons <- mappM tcIdxTyInstDecl ats
@@ -278,11 +274,11 @@ tcLocalInstDecl1 decl@(L loc (InstDecl poly_ty binds uprags ats))
     checkValidAndMissingATs clas inst_tys ats
       = do { -- Issue a warning for each class AT that is not defined in this
             -- instance.
-          ; let classDefATs = listToNameSet . map tyConName . classATs $ clas
-                 definedATs  = listToNameSet . map (tcdName.unLoc.fst)  $ ats
-                omitted     = classDefATs `minusNameSet` definedATs
+          ; let class_ats   = map tyConName (classATs clas)
+                 defined_ats = listToNameSet . map (tcdName.unLoc.fst)  $ ats
+                omitted     = filterOut (`elemNameSet` defined_ats) class_ats
           ; warn <- doptM Opt_WarnMissingMethods
-          ; mapM_ (warnTc warn . omittedATWarn) (nameSetToList omitted)
+          ; mapM_ (warnTc warn . omittedATWarn) omitted
           
             -- Ensure that all AT indexes that correspond to class parameters
             -- coincide with the types in the instance head.  All remaining