[implemented multi-parameter type classes mail@stefanwehr.de**20050527103337] { adddir ./tests/multi-param-typeclasses adddir ./tests/multi-param-typeclasses/should_fail adddir ./tests/multi-param-typeclasses/should_pass adddir ./tests/multi-param-typeclasses/well-formed adddir ./tests/multi-param-typeclasses/well-formed/should_fail adddir ./tests/multi-param-typeclasses/well-formed/should_pass hunk ./Entailment.hs 22 -import Monad ( msum ) +import Monad ( msum, filterM, liftM ) hunk ./Entailment.hs 36 --- `matchConstraint (A, t) c' checks if the constraint c is fulfilled --- by the instance declaration A t. -matchConstraint :: (ClassId, Type) -> ClassConstraint -> ST (Maybe TypeSubst) -matchConstraint (id, t) (ClassConstraint id' t') +-- `matchConstraint (A, ts) c' checks if the constraint c is fulfilled +-- by the instance declaration A ts. +matchConstraint :: (ClassId, [Type]) -> ClassConstraint -> ST (Maybe TypeSubst) +matchConstraint (id, ts) (ClassConstraint id' ts') hunk ./Entailment.hs 44 - tn <- runUF [] (normalise t) - tn' <- runUF [] (normalise t') + tns <- runUF [] (mapM normalise ts) + tns' <- runUF [] (mapM normalise ts') hunk ./Entailment.hs 48 - matchType tn tn' + matchTypes tns tns' hunk ./Entailment.hs 54 -bySuper p@(ClassConstraint i t) = - do superClasses <- findSuperClasses i - transitives <- sequence - [bySuper (ClassConstraint i' t) | i' <- superClasses] +bySuper p@(ClassConstraint i ts) = + do cdec <- findClass i + let s = substFromAssocs (zip (class_params cdec) ts) + superClasses <- findSuperClasses i + transitives <- sequence [bySuper (ClassConstraint i' (applySubst s ts)) + | i' <- superClasses] hunk ./Entailment.hs 65 -byInst p@(ClassConstraint i t) = +byInst p@(ClassConstraint i _) = hunk ./Entailment.hs 79 - do u <- matchConstraint (inst_class ci, inst_type ci) p + do u <- matchConstraint (inst_class ci, inst_types ci) p hunk ./Entailment.hs 117 --- only class constraints are brought into HNF, equality constraints --- are returned untouched -toHnfs :: [Constraint] -> ST [Constraint] -toHnfs ps = let (cs,es) = splitConstraints ps - in do qs <- toHnfs' cs - return (qs ++ map EC es) + +-- We try to bring the class constraints into HNF. However, if this fails +-- for some constraint, we return the constraint unchanged rather than +-- reporting an error. +simplifyToplevel :: [Constraint] -> ST [Constraint] +simplifyToplevel ps = let (cs,es) = splitConstraints ps + in do qs <- toHnfs' cs + return (qs ++ map EC es) hunk ./Entailment.hs 133 - Nothing -> phasefail ("context reduction failed for " - ++ showPpr p) - Just ps -> toHnfs ps - inHnf cc = hnf (cc_param cc) + Nothing -> return [CC p] + Just ps -> simplifyToplevel ps + inHnf cc = all hnf (cc_params cc) hunk ./Entailment.hs 139 - hnf (TyAssoc _) = False -- FIXME: not sure here + hnf (TyAssoc _) = False + +reduceToplevel :: [Constraint] -> ST [Constraint] +reduceToplevel ps = + do debug ("performing top-level context reduction on " ++ + showCommaListed ps) + ps' <- simplifyToplevel ps + debug ("constraints for context reduction are now in HNF: " ++ + showCommaListed ps') + res <- simplify ps' + debug ("reduced " ++ showCommaListed ps ++ " to " ++ showCommaListed res) + return res hunk ./Entailment.hs 159 +elimTauts :: [Constraint] -> ST [Constraint] +elimTauts ps = filterM (liftM not . entail []) ps + hunk ./Entailment.hs 165 - ps' <- toHnfs ps - debug ("constraints for context reduction are now in HNF: " ++ - showCommaListed ps') - res <- simplify ps' + ps' <- simplify ps + res <- elimTauts ps' hunk ./Entailment.hs 170 -split :: [TypeVarId] -- variables in the assumptions - -> [TypeVarId] -- variables we want to quantify over - -> [Constraint] - -> ST ([Constraint], -- deferred constraints - [Constraint]) -- retained constraints -split fs gs ps = +split' :: ([Constraint] -> ST [Constraint]) -- the reduce function + -> [TypeVarId] -- variables in the assumptions + -> [TypeVarId] -- variables we want to quantify over + -> [Constraint] + -> ST ([Constraint], -- deferred constraints + [Constraint]) -- retained constraints +split' red fs gs ps = hunk ./Entailment.hs 180 - ps' <- reduce ps + ps' <- red ps hunk ./Entailment.hs 187 +split = split' reduce +splitToplevel = split' reduceToplevel hunk ./IdMap.hs 75 +dumpMap :: (Pretty k, Pretty a) => Map.Map k a -> Doc +dumpMap m = hcat $ + punctuate (text ", ") + (map (\ (k,v) -> ppr k <+> text "-->" <+> ppr v) + (Map.assocs m)) hunk ./IdMap.hs 81 +dumpIdMap :: (Pretty a, Pretty b, Pretty c, Pretty d, Pretty e, Pretty f) + => IdMap a b c d e f -> Doc +dumpIdMap m = + text "{typeVarMap:" <+> dumpMap (typeVarMap m) $$ + text "typeMap:" <+> dumpMap (typeMap m) $$ + text "valMap:" <+> dumpMap (valMap m) $$ + text "dataMap:" <+> dumpMap (dataMap m) $$ + text "classMap:" <+> dumpMap (classMap m) $$ + text "assocTypeMap:" <+> dumpMap (assocTypeMap m) <> text"}" hunk ./KindInference.hs 60 -type KindEnv = IdMap Kind' Kind' Kind' Kind' Kind' Kind' +type KindEnv = IdMap Kind' Kind' Kind' Kind' [Kind'] Kind' hunk ./KindInference.hs 63 - hunk ./KindInference.hs 164 - allKinds = a ++ b ++ c ++ d ++ e ++ f + allKinds = a ++ b ++ c ++ d ++ concat e ++ f hunk ./KindInference.hs 179 - Right errorMsg -> phasefail errorMsg + Right errorMsg -> + do env <- getEnv + debug ("kind inference about to fail, dumping environment:\n" + ++ show (dumpIdMap env)) + phasefail errorMsg + +unifyList :: [Kind'] -> [Kind'] -> KI () +unifyList ks1 ks2 = mapM_ (uncurry unify) (zip ks1 ks2) hunk ./KindInference.hs 205 - in modifyEnv $ mapIdMap (a, a, a, a, a, a) + in modifyEnv $ mapIdMap (a, a, a, a, map a, a) hunk ./KindInference.hs 345 -kiClassHead (ClassDec name arg constrs tsigs vsigs) = - do varKind <- newKindVar - modifyEnv (\env -> insertClass name varKind - (insertTypeVar arg varKind env)) +kiClassHead (ClassDec name args constrs tsigs vsigs) = + do varKinds <- newKindVars (length args) + modifyEnv (\env -> insertClass name varKinds + (insertTypeVars (zip args varKinds) env)) hunk ./KindInference.hs 356 + + +-- kiClassConstraints and kiClassConstraint work only for constraints on +-- type variables, i.e. constraints which are usually found in the +-- context of a class declaration. hunk ./KindInference.hs 365 -kiClassConstraint (ClassConstraint className (TyVar argName)) = +kiClassConstraint (ClassConstraint className argTypes) = hunk ./KindInference.hs 367 - classKind <- lookupClass className env - argKind <- lookupTypeVar argName env - unify classKind argKind + classKinds <- lookupClass className env + argKinds <- mapM kiType argTypes + unifyList classKinds argKinds + hunk ./KindInference.hs 384 -kiTSig (AssocTypeSig id (index:rest) def) = +kiTSig (AssocTypeSig id params def) = hunk ./KindInference.hs 386 - indexKind <- lookupTypeVar index env + n <- liftST $ getAssocIndexCount id + let indices = take n params + rest = drop n params + indexKinds <- mapM (flip lookupTypeVar $ env) indices hunk ./KindInference.hs 399 - let assocTypeKind = kindFun' (indexKind:restKinds) resultKind + let assocTypeKind = kindFun' (indexKinds ++ restKinds) resultKind hunk ./KindInference.hs 410 - do let vars = freeTypeVarsList (inst_type ci) + do let vars = freeTypeVarsList (inst_types ci) hunk ./KindInference.hs 413 - argKind <- kiType (inst_type ci) + argKinds <- mapM kiType (inst_types ci) hunk ./KindInference.hs 415 - classArgKind <- lookupClass (inst_class ci) env - unify classArgKind argKind + classArgKinds <- lookupClass (inst_class ci) env + unifyList classArgKinds argKinds hunk ./KindInference.hs 433 - indexKind <- kiType (assocBind_index atb) + indexKinds <- mapM kiType (assocBind_indices atb) hunk ./KindInference.hs 438 - unify atKind (kindFun' (indexKind:paramKinds) resKind) + unify atKind (kindFun' (indexKinds ++ paramKinds) resKind) hunk ./ParseSyntax.hs 84 - class_param :: TypeVarId, + class_params :: [TypeVarId], hunk ./ParseSyntax.hs 99 - inst_type :: Type, + inst_types :: [Type], hunk ./ParseSyntax.hs 107 - assocBind_index :: Type, + assocBind_indices :: [Type], hunk ./ParseSyntax.hs 119 - cc_param :: Type + cc_params :: [Type] hunk ./ParseSyntax.hs 239 +isTypeVar :: Type -> Bool +isTypeVar (TyVar _) = True +isTypeVar _ = False + +maybeTypeVar :: Monad m => Type -> m TypeVarId +maybeTypeVar (TyVar i) = return i +maybeTypeVar t = fail ("not a type variable: " ++ showPpr' t) + hunk ./ParseSyntax.hs 465 - ppr (ClassConstraint name param) = - ppr name <+> pprPrec maxPrec param + ppr (ClassConstraint name params) = + ppr name <+> pprList " " (map (pprPrec maxPrec) params) hunk ./ParseSyntax.hs 469 - ppr (ClassInst name ty constrs tyBind valBinds) = + ppr (ClassInst name tys constrs tyBind valBinds) = hunk ./ParseSyntax.hs 471 - <+> text "=>" <+> ppr name <+> pprPrec maxPrec ty <+> text "where" $$ + <+> text "=>" <+> ppr name <+> pprList " " (map (pprPrec maxPrec) tys) + <+> text "where" $$ hunk ./ParseSyntax.hs 476 - ppr (AssocTypeBind name index params def) = - ppr name <+> pprPrec maxPrec index <+> hsep (map ppr params) - <+> text "=" <+> ppr def + ppr (AssocTypeBind name indices params def) = + ppr name <+> pprList " " (map (pprPrec maxPrec) indices) + <+> hsep (map ppr params) <+> text "=" <+> ppr def hunk ./ParseSyntax.hs 495 - ppr (ClassDec name param constrs tsigs vsigs) = + ppr (ClassDec name params constrs tsigs vsigs) = hunk ./ParseSyntax.hs 497 - <+> text "=>" <+> ppr name <+> ppr param <+> text "where" $$ + <+> text "=>" <+> ppr name <+> pprList " " params <+> text "where" $$ hunk ./ParseSyntax.hs 577 - show (ppr (inst_class ci) <+> pprPrec maxPrec (inst_type ci)) + show (ppr (inst_class ci) <+> + pprList " " (map (pprPrec maxPrec) (inst_types ci))) hunk ./ParseSyntax.hs 582 - show (ppr (class_name cd) <+> pprPrec maxPrec (class_param cd)) + show (ppr (class_name cd) <+> + pprList " " (map (pprPrec maxPrec) (class_params cd))) hunk ./Parser.y 148 - : 'type' tycon atype etyvars '=' type - { (AssocTypeBind $2 $3 (reverse $4) $6) } - + : 'type' tycon atypes '=' type + { (AssocTypeBind $2 $3 [] $5) } hunk ./ParserHelper.hs 55 -mkClassDec (cs, (TyApp (TyConstruct i) (TyVar v))) tsigs vsigs = - ClassDec i v (map toClassConstraint cs) tsigs vsigs +mkClassDec (cs, t) tsigs vsigs = + ClassDec i vs (map toClassConstraint cs) tsigs vsigs hunk ./ParserHelper.hs 60 -mkClassDec _ _ _ = phasefail "illegal class declaration" + (i, vs) = let (i', ts) = case splitType t of + Just x -> x + Nothing -> + phasefail "illegal class declaration" + f (TyVar id) = id + f _ = phasefail ("illegal class declaration " + ++ showPpr' i') + in (i', map f ts) hunk ./ParserHelper.hs 71 -mkClassInst (cs, (TyApp (TyConstruct i) t)) assocs vals = - ClassInst i t cs assocs vals -mkClassInst (cs, t) _ _ = - phasefail ("illegal instance type: " ++ showPpr' t) +mkClassInst (cs, t) assocs vals = + let (i, ts) = case splitType t of + Just x -> x + Nothing -> phasefail "illegal instance declaration" + in ClassInst i ts cs assocs vals + +splitType :: Type -> Maybe (TypeId, [Type]) +splitType (TyApp (TyConstruct i) t) = return (i, [t]) +splitType (TyApp t1 t2) = + do (i, ts) <- splitType t1 + return (i, ts ++ [t2]) +splitType t = fail ("cannot split type " ++ showPpr' t) hunk ./ParserHelper.hs 97 -mkClassConstraint (TyApp (TyConstruct i) t) = ClassConstraint i t -mkClassConstraint t@(_) = phasefail ("Illegal class constraint: " ++ - show (ppr t)) +mkClassConstraint t = + let (i, ts) = case splitType t of + Just x -> x + Nothing -> phasefail ("Illegal class constraint: " ++ + show (ppr t)) + in ClassConstraint i ts hunk ./Symtab.hs 35 - findDataConstructor, findMethodSig, + findDataConstructor, findMethodSig, getAssocIndexCount, hunk ./Symtab.hs 123 +-- returns the number of index parameter of an associated type synonym +getAssocIndexCount :: AssocTypeId -> ST Int +getAssocIndexCount id = + do cdec <- findClassOfAssocType id + return (length $ class_params cdec) + hunk ./Symtab.hs 272 - quants = freeTypeVarsList (inst_type ci) + quants = freeTypeVarsList (inst_types ci) hunk ./Symtab.hs 285 - (assocBind_index assoc : + (assocBind_indices assoc ++ hunk ./SyntaxTransformation.hs 72 - defineClass (ClassDec name _ _ tsigs valsigs) = + defineClass cd@(ClassDec name _ _ tsigs valsigs) = hunk ./SyntaxTransformation.hs 74 - mapM (\ sig -> defineAssocTypeCon $ assocSig_name sig) tsigs + let n = length (class_params cd) + mapM (\ sig -> defineAssocTypeCon (assocSig_name sig) n) tsigs hunk ./SyntaxTransformation.hs 100 -rw_classdec (ClassDec name param constrs tsigs vsigs) = +rw_classdec (ClassDec name params constrs tsigs vsigs) = hunk ./SyntaxTransformation.hs 102 - param' <- defineTypeVar param + params' <- mapM defineTypeVar params hunk ./SyntaxTransformation.hs 105 - vsigs' <- mapM (rw_vsig name param) vsigs - undefineTypeVar param' - return $ AS.ClassDec uid param' constrs' tsigs' vsigs' + vsigs' <- mapM rw_vsig vsigs + mapM undefineTypeVar params' + return $ AS.ClassDec uid params' constrs' tsigs' vsigs' hunk ./SyntaxTransformation.hs 109 -rw_tsig :: AssocTypeSig -> NA AS.AssocTypeSig -rw_tsig (AssocTypeSig id [] _) = - phasefail "invalid declaration of associated type synonym: \ - \no arguments specified" - -rw_tsig (AssocTypeSig id (t:ts) def) = - do uid <- lookUpAssocTypeCon id - t' <- lookUpTypeVar t - ts' <- mapM defineTypeVar ts +rw_tsig (AssocTypeSig id ts def) = + do (uid, n) <- lookUpAssocTypeCon id + let indices = take n ts + params = drop n ts + if length indices /= n + then phasefail ("invalid declaration of associated type synonym " ++ + showPpr' id) + else return () + indices' <- mapM lookUpTypeVar indices + params' <- mapM defineTypeVar params hunk ./SyntaxTransformation.hs 123 - mapM undefineTypeVar ts' - return (AS.AssocTypeSig uid (t':ts') def') + mapM undefineTypeVar params' + return (AS.AssocTypeSig uid (indices' ++ params') def') hunk ./SyntaxTransformation.hs 126 -rw_vsig:: ClassId -> TypeVarId -> VSig -> NA AS.VSig -rw_vsig cid tv (i, sc) = +rw_vsig:: VSig -> NA AS.VSig +rw_vsig (i, sc) = hunk ./SyntaxTransformation.hs 141 -rw_classinst (ClassInst name param constrs tyBinds valBinds) = - do let vars = Set.toList $ freeTypeVars param +rw_classinst (ClassInst name params constrs tyBinds valBinds) = + do let vars = Set.toList $ freeTypeVars params hunk ./SyntaxTransformation.hs 145 - param' <- rw_type param + params' <- mapM rw_type params hunk ./SyntaxTransformation.hs 150 - return (AS.ClassInst uid param' constrs' tyBinds' valBinds') + return (AS.ClassInst uid params' constrs' tyBinds' valBinds') hunk ./SyntaxTransformation.hs 172 -rw_constraint (CC (ClassConstraint i t)) = +rw_constraint (CC (ClassConstraint i ts)) = hunk ./SyntaxTransformation.hs 174 - t' <- rw_type t - return (AS.CC (AS.ClassConstraint uid t')) + ts' <- mapM rw_type ts + return (AS.CC (AS.ClassConstraint uid ts')) hunk ./SyntaxTransformation.hs 177 - do uid <- lookUpAssocTypeCon id + do (uid, _) <- lookUpAssocTypeCon id hunk ./SyntaxTransformation.hs 182 +-- the parser stores all parameter in indices hunk ./SyntaxTransformation.hs 184 -rw_assocTypeBind (AssocTypeBind id index params ty) = - do uid <- lookUpAssocTypeCon id - index' <- rw_type index - params' <- mapM defineTypeVar params +rw_assocTypeBind (AssocTypeBind id indices _ ty) = + do (uid, i) <- lookUpAssocTypeCon id + let realIndices = take i indices + params = drop i indices + paramVars = mapMaybe maybeTypeVar params + if length params /= length paramVars + then phasefail ("illegal assoc type definition: at least one of the " + ++ "additional parameters is not a type variable") + else return () + indices' <- mapM rw_type realIndices + params' <- mapM defineTypeVar paramVars hunk ./SyntaxTransformation.hs 197 - return (AS.AssocTypeBind uid index' params' ty') + return (AS.AssocTypeBind uid indices' params' ty') hunk ./SyntaxTransformation.hs 245 - then do uid <- lookUpAssocTypeCon tc + then do (uid,_) <- lookUpAssocTypeCon tc hunk ./TypeInference.hs 38 -import Entailment ( entail, split, reduce ) +import Entailment ( entail, split, splitToplevel, reduce ) hunk ./TypeInference.hs 168 - do (ps, as') <- tiBindGroup as binds + do (ps, as') <- tiBindGroup NestedLevel as binds hunk ./TypeInference.hs 245 - do info ("typing explicitly typed binding " ++ showPpr' i) + do -- we check for ambiguity first because ambiguous signatures may + -- not pass the subsumption check, although the look like they should + checkForAmbiguity (i, sc) + info ("typing explicitly typed binding " ++ showPpr' i) hunk ./TypeInference.hs 279 + +data Level = TopLevel | NestedLevel deriving (Show,Eq) hunk ./TypeInference.hs 283 -tiImpls :: Infer [Impl] Assumps -tiImpls as bs = +tiImpls :: Level -> Infer [Impl] Assumps +tiImpls level as bs = hunk ./TypeInference.hs 306 - (ds, rs) <- liftST $ split (Set.toList fs) + let mySplit = if level == TopLevel then splitToplevel else split + (ds, rs) <- liftST $ mySplit (Set.toList fs) hunk ./TypeInference.hs 348 -tiImplsSeq :: Infer [[Impl]] Assumps -tiImplsSeq as [] = return ([], emptyAssumps) -tiImplsSeq as (bs:bss) = - do (ps, as') <- tiImpls as bs - (qs, as'') <- tiImplsSeq (as' `merge` as) bss +tiImplsSeq :: Level -> Infer [[Impl]] Assumps +tiImplsSeq _ as [] = return ([], emptyAssumps) +tiImplsSeq level as (bs:bss) = + do (ps, as') <- tiImpls level as bs + (qs, as'') <- tiImplsSeq level (as' `merge` as) bss hunk ./TypeInference.hs 355 -tiBindGroup :: Infer [ValBind] Assumps -tiBindGroup as binds = +tiBindGroup :: Level -> Infer [ValBind] Assumps +tiBindGroup level as binds = hunk ./TypeInference.hs 363 - (ps, as'') <- tiImplsSeq (as' `merge` as) (splitImpls impls) + (ps, as'') <- tiImplsSeq level (as' `merge` as) (splitImpls impls) hunk ./TypeInference.hs 384 - checkForAmbiguity :: (ValId, TypeScheme) -> TI () - checkForAmbiguity (id, sc@(TypeScheme alphas rho)) = - let fv_rho = freeTypeVars rho - fixv_rho = fixedTypeVars rho - in if not ((Set.fromList alphas `Set.intersection` fv_rho) - `Set.isSubsetOf` fixv_rho) - || - -- because of the monomorphism restriction, signatures - -- such as forall a . C b => a -> Int may arise so that - -- we need an additional check (maybe this check is - -- too restrictive, but this is ok for now) - not (freeTypeVars (qtype_context rho) `Set.isSubsetOf` - freeTypeVars (qtype_mono rho)) - then phasefail ("ambiguous signature for " ++ showPpr' id - ++ ": " ++ showPpr sc) - else return () + +checkForAmbiguity :: (ValId, TypeScheme) -> TI () +checkForAmbiguity (id, sc@(TypeScheme alphas rho)) = + let fv_rho = freeTypeVars rho + fixv_rho = fixedTypeVars rho + in if not ((Set.fromList alphas `Set.intersection` fv_rho) + `Set.isSubsetOf` fixv_rho) + || + -- because of the monomorphism restriction, signatures + -- such as forall a . C b => a -> Int may arise so that + -- we need an additional check (maybe this check is + -- too restrictive, but this is ok for now) + not (freeTypeVars (qtype_context rho) `Set.isSubsetOf` + freeTypeVars (qtype_mono rho)) + then phasefail ("ambiguous signature for " ++ showPpr' id + ++ ": " ++ showPpr sc) + else return () hunk ./TypeInference.hs 407 - dumpAssumps as ++ "\n" ++ dumpConstraints ps ++ - "\npossible reason: monomorphism restriction applied " - ++ "to a top-level binding") - else return as + dumpAssumps as ++ "\n" ++ dumpConstraints ps) + else do normed <- norm as + return normed hunk ./TypeInference.hs 416 - (ps, as') <- tiBindGroup as binds + (ps, as') <- tiBindGroup TopLevel as binds hunk ./TypeInference.hs 422 - -- for a method declaration in class `D a', we must add the - -- `D a' to the constraints and `a' to the quantified variables - -- of its signature. + -- for a method declaration in class `D a1 .. aN', we must add the + -- `D a1 .. aN' to the constraints and `a1 .. aN' to the quantified + -- variables of its signature. hunk ./TypeInference.hs 428 - (TyVar (class_param cdec)) + (map TyVar (class_params cdec)) hunk ./TypeInference.hs 430 - TypeScheme (nub (class_param cdec : qs)) + TypeScheme (nub (class_params cdec ++ qs)) hunk ./TypeInference.hs 436 - do info ("checking methods of instance `" ++ - show (ppr (inst_class ci) <+> - pprPrec maxPrec (inst_type ci)) ++ "'") + do info ("checking methods of instance `" ++ showInstHead ci + ++ "'") hunk ./TypeInference.hs 447 - t' = applySubst (class_param cdec +-> inst_type ci) t - qs' = List.nub (qs ++ freeTypeVarsList (inst_type ci)) + subst = substFromAssocs (zip (class_params cdec) + (inst_types ci)) + t' = applySubst subst t + qs' = List.nub (qs ++ freeTypeVarsList (inst_types ci)) hunk ./TypeInference.hs 453 - " of class " ++ showPpr cid ++ " in instance for " - ++ showPpr' (inst_type ci) ++ ". Expected type: " ++ + " in " ++ showInstHead ci ++ ". Expected type: " ++ hunk ./TypeInference.hs 461 - + norm :: Assumps -> ST Assumps + norm as = + do l <- mapM (\ (k, TypeScheme quants (QualifiedType ps t)) -> + do t' <- runUF [] (normalise t) + return (k, TypeScheme quants + (QualifiedType ps t'))) + (Map.assocs as) + return $ Map.fromList l hunk ./Unification.hs 26 - matchType, normalise, + matchType, matchTypes, normalise, hunk ./UniqIdents.hs 145 - | AssocTypeCon AssocTypeId + | AssocTypeCon AssocTypeId Int-- number of indices hunk ./UniqIdents.hs 208 -defineAssocTypeCon :: ParseId -> NA AssocTypeId -defineAssocTypeCon = defineType AssocTypeId AssocTypeCon - Map.insertLookup "associated type constructor" +defineAssocTypeCon :: ParseId -> Int -> NA AssocTypeId +defineAssocTypeCon id arity = + defineType AssocTypeId (flip AssocTypeCon arity) + Map.insertLookup "associated type constructor" id hunk ./UniqIdents.hs 252 -lookUpAssocTypeCon :: ParseId -> NA AssocTypeId +lookUpAssocTypeCon :: ParseId -> NA (AssocTypeId, Int) hunk ./UniqIdents.hs 254 - AssocTypeCon uid -> Just uid + AssocTypeCon uid i -> Just (uid, i) hunk ./UniqIdents.hs 270 - Just (AssocTypeCon _) -> return True + Just (AssocTypeCon _ _) -> return True hunk ./WellFormedness.hs 60 - c = CC $ ClassConstraint cid (TyVar $ class_param cdec) + c = CC $ ClassConstraint cid (map TyVar $ class_params cdec) hunk ./WellFormedness.hs 69 - do debug ("checking associated type definitions in instance of class " ++ - showPpr' (inst_class ci) ++ " for type " ++ - showPpr' (inst_type ci)) + do debug ("checking associated type definitions in instance " ++ + showInstHead ci) hunk ./WellFormedness.hs 89 - let t1 = inst_type i1 - t2 = inst_type i2 - in do ures <- runUnify [] [t1 :=: t2] + let ts1 = inst_types i1 + ts2 = inst_types i2 + in do ures <- runUnify [] (map (\ (x,y) -> x :=: y) (zip ts1 ts2)) hunk ./WellFormedness.hs 105 +-- {missing_superclass_instance.phc} hunk ./WellFormedness.hs 115 - do let c = CC $ ClassConstraint cid (inst_type ci) + do let c = CC $ ClassConstraint cid (inst_types ci) hunk ./WellFormedness.hs 128 + Gen.everywhereM (Gen.mkM checkClassConstraint) p hunk ./WellFormedness.hs 140 --- FIXME: need symbol table and cycle check hunk ./WellFormedness.hs 152 - --- An associated type synonym must be parameterised over all --- parameters of the class, and these type variables must come first, --- and be in the same order as in the class. --- {illegal_assoc_decl1.mhs, illegal_assoc_decl2.mhs} - --- => for single parameter type classes, this property is guaranteed by --- the syntax transformation. hunk ./WellFormedness.hs 160 - where checkConstr (ClassConstraint _ (TyVar _)) = - return () -- syntax transformation guarantees that only - -- class variables are constrained - checkConstr (ClassConstraint _ _) = - phasefail ("illegal context for class " ++ showPpr id ++ - ": only type variables can be constrained") + where checkConstr (ClassConstraint _ ts) = + if all isTypeVar ts + then return () -- syntax transformation guarantees that only + -- class variables are constrained + else + phasefail ("illegal context for class " ++ showPpr id ++ + ": only type variables can be constrained") hunk ./WellFormedness.hs 168 --- checks the well-formedness of fixed associated type synonyms -checkTypeSigs (ClassDec id param constrs tsigs _) = +-- An associated type synonym must be parameterised over all +-- parameters of the class, and these type variables must come first, +-- and be in the same order as in the class. +-- {illegal_assoc_decl1.mhs, illegal_assoc_decl2.mhs} +-- types of fixed associated type synonyms must be well-formed +-- (see tests in tests/fixed-assoc-types) +checkTypeSigs (ClassDec id classParams constrs tsigs _) = hunk ./WellFormedness.hs 177 - checkTypeSig (AssocTypeSig _ _ Nothing) = return () - checkTypeSig (AssocTypeSig aid ps (Just t)) = - do debug ("checking fixed associated type synonym " ++ showPpr' aid) - checkType (map CC constrs) t - case ps of - [] -> panic ("illegal associated type synonym definition in class." - ++ " parameter list empty") - (x:xs) -> - do conf <- getConfiguration - if typeSynonymTermination conf == DecreasingConstructorCount - then checkDecreasingAssocTypeDefinition - (AssocTypeBind aid (TyVar x) xs t) - else return () + checkTypeSig (AssocTypeSig aid ps t) = + do debug ("checking associated type synonym " ++ showPpr' aid) + let n = length classParams + indices = take n ps + params = drop n ps + if indices /= classParams + then phasefail ("signature of associated type synonym " ++ + showPpr aid ++ " does not repeat the class " ++ + "parameters") + else return () + case t of + Nothing -> return () + Just t' -> + do checkType (map CC constrs) t' + conf <- getConfiguration + if typeSynonymTermination conf == DecreasingConstructorCount + then checkDecreasingAssocTypeDefinition + (AssocTypeBind aid (map TyVar indices) params t') + else return () hunk ./WellFormedness.hs 202 -checkMethodSigs (ClassDec id param _ _ msigs) = +checkMethodSigs (ClassDec id params _ _ msigs) = hunk ./WellFormedness.hs 209 - if param `Set.member` freeTypeVars cs + if not $ null (params `List.intersect` freeTypeVarsList cs) hunk ./WellFormedness.hs 212 - showPpr id ++ " constrains the class parameter") + showPpr id ++ " constrains some class parameter") hunk ./WellFormedness.hs 215 - if not $ param `Set.member` fixedTypeVars sc + if not $ Set.fromList params `Set.isSubsetOf` fixedTypeVars sc hunk ./WellFormedness.hs 229 -checkInstanceDec ci@(ClassInst clazz ty constrs tyBinds methodBinds) = - do mapM checkConstraint constrs +checkInstanceDec ci@(ClassInst clazz tys constrs tyBinds methodBinds) = + do cdec <- findClass clazz + if length (class_params cdec) /= length tys + then phasefail ("illegal instance declaration for class " ++ + showPpr' clazz ++ ": wrong number of arguments") + else return () + mapM checkConstraint constrs hunk ./WellFormedness.hs 248 -checkConstructorBased (ClassInst clazz (TyVar _) _ _ _) = - phasefail ("illegal instance declaration for class " ++ showPpr clazz ++ - ": single type variable not allowed in instance head") -checkConstructorBased (ClassInst clazz ty _ _ _) = - let vars = allTypeVars ty - in if length vars /= length (List.nub vars) +checkConstructorBased (ClassInst clazz tys _ _ _) = + let vars = concatMap allTypeVars tys + in do if length vars /= length (List.nub vars) hunk ./WellFormedness.hs 253 + else return () + if all isTypeVar tys + then phasefail ("illegal instance definition: all parameters " ++ + "are type variables") hunk ./WellFormedness.hs 259 --- All constraints in the instance context must be of the form C a (where --- C is a class and a is a type variable) or T a1..aN = t (where T a1..aN --- is the saturated application of an associated type synonym and t is --- a type but not a single variable; all arguments to synonym applications --- in t must be variables). +-- All constraints in the instance context must be of the form C a1 .. aN +-- (where C is a class and the aI are type variables) or T a1..aN = t +-- (where T a1..aN is the saturated application of an associated type synonym +-- and t is a type but not a single variable; all arguments to synonym +-- applications in t must be variables). hunk ./WellFormedness.hs 270 - checkConstraint c@(CC (ClassConstraint _ ty)) = - case ty of - TyVar _ -> return () - _ -> phasefail ("illegal constraint in instance declaration for " ++ + checkConstraint c@(CC (ClassConstraint _ tys)) = + if all isTypeVar tys + then return () + else phasefail ("illegal constraint in instance declaration for " ++ hunk ./WellFormedness.hs 338 - if length params /= 1 + (length $ assocBind_params at) + if length params /= (length $ assocBind_indices at) + + (length $ assocBind_params at) hunk ./WellFormedness.hs 343 - if assocBind_index at /= inst_type ci + if assocBind_indices at /= inst_types ci hunk ./WellFormedness.hs 372 -checkDecreasingAssocTypeDefinition (AssocTypeBind id p ps ty) = - do let m = dataConstructorCount p +checkDecreasingAssocTypeDefinition (AssocTypeBind id indices params ty) = + do let m = sum (map dataConstructorCount indices) hunk ./WellFormedness.hs 434 --- in equality constraints, the 1st argument of the type synonym application --- in the left side must be a type variable. +-- in equality constraints, the first n arguments (where n is the number of +-- class parameter of the class defining the synonym) of the type synonym +-- applications in the left side must be type variables. hunk ./WellFormedness.hs 441 -checkConstraint (EC (EqConstraint (AssocType _ (TyVar _ : _)) _)) = return () -checkConstraint (EC (EqConstraint (AssocType name _) _)) = - phasefail ("invalid associated type synonym `" ++ showPpr name ++ - "' in equality constraint (first parameter is not a variable)") +checkConstraint (EC (EqConstraint (AssocType name params) _)) = + do n <- getAssocIndexCount name + if not (all isTypeVar (take n params)) + then phasefail ("invalid associated type synonym `" ++ showPpr name + ++ "' in equality constraint (one of the index " ++ + "parameters is not a variable)") + else return () hunk ./WellFormedness.hs 500 - let c = case params of - [] -> panic ("empty argument list for associated type " ++ - showPpr' id) - (t:_) -> CC $ ClassConstraint (class_name cd) t + let indices = take (length $ class_params cd) params + let c = CC $ ClassConstraint (class_name cd) indices hunk ./WellFormedness.hs 509 + + +-- check that a class constraint uses the right number of arguments +checkClassConstraint :: ClassConstraint -> ST ClassConstraint +checkClassConstraint cc@(ClassConstraint id params) = + do cdec <- findClass id + if length params /= length (class_params cdec) + then phasefail ("illegal class constraint: " ++ showPpr' cc ++ + ": wrong number of arguments") + else return cc + hunk ./tests/examples/HList.out 1 +list1 :: HCons Int (HCons Bool HNil) +list2 :: HCons (Int, Int) (HCons Bool (HCons (Int -> Int) HNil)) +list3 :: HCons Int (HCons Bool (HCons (Int, Int) (HCons Bool (HCons (Int -> Int) HNil)))) hunk ./tests/examples/HList.phc 8 --- does not work atm, need multi-parameter typeclasses --- class HAppendC l l' where { --- type HAppend l l'; --- hAppend :: l -> l' -> HAppend l l'; --- } +class HAppendC l l' where { + type HAppend l l'; + hAppend :: l -> l' -> HAppend l l'; +} + +instance HList l => HAppendC HNil l where { + type HAppend HNil l = l; + hAppend x l = l; +} + +instance HList l, HAppendC l l' => HAppendC (HCons x l) l' where { + type HAppend (HCons x l) l' = HCons x (HAppend l l'); + hAppend y l' = case y of HCons x l -> HCons x (hAppend l l');; +} + +list1 = HCons 42 (HCons True HNil); + +list2 = HCons (1,0) (HCons False (HCons (\x -> x + 1) HNil)); + +list3 = hAppend list1 list2; hunk ./tests/examples/TypeSaveEvaluator.out 1 -foo :: forall v[-2] . Result v[-2] = Int, Eval v[-2] => v[-2] -> Result (If (IsZero (Succ v[-2])) (Lit Int) v[-2]) -bar :: Result (If (IsZero (Succ (Lit Int))) (Lit Int) (Lit Int)) +foo :: forall v[-2] . Result v[-2] = Int, Eval v[-2] => v[-2] -> Int +bar :: Int hunk ./tests/fixed-assoc-types/should_pass/000.out 1 -foo :: forall a[1] . C a[1] => a[1] -> T a[1] +foo :: forall a[1] . C a[1] => a[1] -> Int hunk ./tests/fixed-assoc-types/should_pass/allow-diverge/000.out 1 -foo :: T Bool +foo :: Int addfile ./tests/multi-param-typeclasses/should_pass/000.out hunk ./tests/multi-param-typeclasses/should_pass/000.out 1 +bar :: forall v[-5] v[-4] . C Int v[-4] v[-5] => v[-4] v[-5] -> T Int v[-4] v[-5] addfile ./tests/multi-param-typeclasses/should_pass/000.phc hunk ./tests/multi-param-typeclasses/should_pass/000.phc 1 +data D x y = D (x y); + +class C a b c where { + type T a b c; + foo :: a -> b c -> T a b c; +} + +instance C Int b Bool where { + type T Int b Bool = D b Bool; + foo x y = D y; +} + +--bar :: C Int b Bool => b Bool -> T Int b Bool; +bar z = foo 42 z; addfile ./tests/multi-param-typeclasses/should_pass/Flag hunk ./tests/multi-param-typeclasses/should_pass/Flag 1 +--dump-infer addfile ./tests/multi-param-typeclasses/well-formed/should_fail/Flag hunk ./tests/multi-param-typeclasses/well-formed/should_fail/Flag 1 +expect-fail --no-location addfile ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous1.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous1.err 1 +type variable `b' does not exist addfile ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous1.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous1.phc 1 +class C a b where { +} + +foo :: C a b => a -> Int; +foo = foo; addfile ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous2.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous2.err 1 +ambiguous signature for `foo': forall a[1] b[1] . C a[1] b[1] => a[1] -> T a[1] b[1] addfile ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous2.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous2.phc 1 +class C a b where { + type T a b; +} + +foo :: C a b => a -> T a b; +foo = foo; + + addfile ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous3.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous3.err 1 +signature of method foo of class C is invalid. addfile ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous3.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/ambiguous3.phc 1 +class C a b where { + type T a b; + foo :: a -> T a b; +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/constrain_class_param.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/constrain_class_param.err 1 +signature of method foo of class C constrains some class parameter addfile ./tests/multi-param-typeclasses/well-formed/should_fail/constrain_class_param.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/constrain_class_param.phc 1 +class X a where { +} + +class C a b where { + foo :: X a => a -> b; +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_assoc_definition.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_assoc_definition.err 1 +illegal assoc type definition: at least one of the additional parameters is not a type variable addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_assoc_definition.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_assoc_definition.phc 1 +class C a b where { + type T a b c; +} + +instance C Int Bool where { + type T Int Bool Bool = Int; +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_class_constraint.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_class_constraint.err 1 +illegal context for class D: only type variables can be constrained addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_class_constraint.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_class_constraint.phc 1 +class C a b where { +} + +class C a Int => D a where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_eq_constraint.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_eq_constraint.err 1 +invalid associated type synonym `T' in equality constraint (one of the index parameters is not a variable) addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_eq_constraint.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_eq_constraint.phc 1 +class C a b where { + type T a b; +} + +foo :: C a Int, T a Int = Bool => a -> Int; +foo = foo; addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_constraint.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_constraint.err 1 +illegal constraint in instance declaration for class C: C Int b[1] addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_constraint.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_constraint.phc 1 +class C a b where { +} + +instance C Int b => C b Bool where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_head.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_head.err 1 +duplicate type variable in head of instance for class C addfile ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_head.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/illegal_instance_head.phc 1 +class C a b c where { +} + +instance C Int b b where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/not_constructor_based.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/not_constructor_based.err 1 +illegal instance definition: all parameters are type variables addfile ./tests/multi-param-typeclasses/well-formed/should_fail/not_constructor_based.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/not_constructor_based.phc 1 +class C a b where { +} + +instance C x y where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/not_wellformed_type.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/not_wellformed_type.err 1 +illegal associated type application: `T a[1] Bool'. Cannot deduce `C a[1] Bool' from program context and {C a[1] b[1]} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/not_wellformed_type.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/not_wellformed_type.phc 1 +class C a b where { + type T a b; +} + +foo :: C a b => T a Bool -> b; +foo = foo; addfile ./tests/multi-param-typeclasses/well-formed/should_fail/overlapping.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/overlapping.err 1 +overlapping instances for class C addfile ./tests/multi-param-typeclasses/well-formed/should_fail/overlapping.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/overlapping.phc 1 +class C a b where { +} + +instance C Int Bool where { +} + +instance C Bool Int where { +} + +instance C a Int where { +} + addfile ./tests/multi-param-typeclasses/well-formed/should_fail/repeated_var.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/repeated_var.err 1 +type variable `a' already defined addfile ./tests/multi-param-typeclasses/well-formed/should_fail/repeated_var.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/repeated_var.phc 1 +class C a a where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number1.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number1.err 1 +illegal instance declaration for class `C': wrong number of arguments addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number1.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number1.phc 1 +class C a b c where { +} + +instance C Int Bool where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number2.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number2.err 1 +illegal class constraint: `C a[1]': wrong number of arguments addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number2.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number2.phc 1 +class C a b where { +} + +foo :: C a => a -> Int; +foo = foo; addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number3.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number3.err 1 +illegal class constraint: `C c': wrong number of arguments addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number3.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number3.phc 1 +class C a b where { + foo :: C c => a -> b -> c; +} addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number4.err hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number4.err 1 +illegal class constraint: `C a[1]': wrong number of arguments addfile ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number4.phc hunk ./tests/multi-param-typeclasses/well-formed/should_fail/wrong_param_number4.phc 1 +class C a b where { +} + +class C a => D a where { +} addfile ./tests/multi-param-typeclasses/well-formed/should_pass/assoc_type_def.out addfile ./tests/multi-param-typeclasses/well-formed/should_pass/assoc_type_def.phc hunk ./tests/multi-param-typeclasses/well-formed/should_pass/assoc_type_def.phc 1 +data D t = D t; + +class C a b where { + type T a b c; +} + +instance C Int Bool where { + type T Int Bool c = D c; +} addfile ./tests/multi-param-typeclasses/well-formed/should_pass/constructor_based.out addfile ./tests/multi-param-typeclasses/well-formed/should_pass/constructor_based.phc hunk ./tests/multi-param-typeclasses/well-formed/should_pass/constructor_based.phc 1 +class C a b where { +} + +instance C a Int where { +} hunk ./tests/type-inference/should_fail/012.err 1 -context reduction failed for C Int +deferred constraints left after type inference: +{Assumptions: {f = Int, foo = forall a . C a => a -> Int}} +{Constraints: {C Int}} hunk ./tests/type-inference/should_fail/013.err 1 -context reduction failed for C Int +deferred constraints left after type inference: +{Assumptions: {bar = Int, foo = forall a[1] . C a[1] => a[1] -> Int}} +{Constraints: {C Int}} hunk ./tests/type-inference/should_fail/017.err 4 -possible reason: monomorphism restriction applied to a top-level binding hunk ./tests/well-formed/should_fail/constrain_class_param.err 1 -signature of method foo of class C2 constrains the class parameter +signature of method foo of class C2 constrains some class parameter hunk ./tests/well-formed/should_fail/constrain_class_param.phc 4 - -- does not parse atm hunk ./tests/well-formed/should_fail/eq_constraint1.err 1 -invalid associated type synonym `T' in equality constraint (first parameter is not a variable) +invalid associated type synonym `T' in equality constraint (one of the index parameters is not a variable) hunk ./tests/well-formed/should_fail/eq_constraint2.err 1 -invalid associated type synonym `T' in equality constraint (first parameter is not a variable) +invalid associated type synonym `T' in equality constraint (one of the index parameters is not a variable) hunk ./tests/well-formed/should_fail/eq_constraint3.err 1 -invalid associated type synonym `T' in equality constraint (first parameter is not a variable) +invalid associated type synonym `T' in equality constraint (one of the index parameters is not a variable) hunk ./tests/well-formed/should_fail/eq_constraint4.err 1 -invalid associated type synonym `T' in equality constraint (first parameter is not a variable) +invalid associated type synonym `T' in equality constraint (one of the index parameters is not a variable) hunk ./tests/well-formed/should_fail/illegal_assoc_decl1.err 1 -illegal class declaration +signature of associated type synonym T does not repeat the class parameters hunk ./tests/well-formed/should_fail/illegal_assoc_decl2.err 1 -illegal class declaration +type variable `c' does not exist hunk ./tests/well-formed/should_fail/instance_for_tyvar.err 1 -illegal instance declaration for class C: single type variable not allowed in instance head +illegal instance definition: all parameters are type variables }