@@ -44,9 +44,14 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
4444
4545 f :: Declaration -> MultipleErrors
4646 f (PositionedDeclaration pos _ dec) = addHint (PositionedError pos) (f dec)
47− f dec@(ValueDeclaration name _ _ _) = addHint (ErrorInValueDeclaration name) (warningsInDecl moduleNames dec <> checkTypeVarsInDecl dec)
48− f (TypeDeclaration name ty) = addHint (ErrorInTypeDeclaration name) (checkTypeVars ty)
49− f dec = warningsInDecl moduleNames dec <> checkTypeVarsInDecl dec
47+ f (TypeClassDeclaration name args _ _ decs) = addHint (ErrorInTypeClassDeclaration name) (foldMap (f' (S.fromList $ fst <$> args)) decs)
48+ f dec = f' S.empty dec
49+
50+ f' :: S.Set String -> Declaration -> MultipleErrors
51+ f' s (PositionedDeclaration pos _ dec) = addHint (PositionedError pos) (f' s dec)
52+ f' s dec@(ValueDeclaration name _ _ _) = addHint (ErrorInValueDeclaration name) (warningsInDecl moduleNames dec <> checkTypeVarsInDecl s dec)
53+ f' s (TypeDeclaration name ty) = addHint (ErrorInTypeDeclaration name) (checkTypeVars s ty)
54+ f' s dec = warningsInDecl moduleNames dec <> checkTypeVarsInDecl s dec
5055
5156 stepE :: S.Set Ident -> Expr -> MultipleErrors
5257 stepE s (Abs (Left name) _) | name `S.member` s = errorMessage (ShadowedName name)
@@ -70,11 +75,11 @@ lint (Module _ _ mn ds _) = censor (addHint (ErrorInModule mn)) $ mapM_ lintDecl
7075 | otherwise = mempty
7176 stepDo _ _ = mempty
7277
73− checkTypeVarsInDecl :: Declaration -> MultipleErrors
74− checkTypeVarsInDecl d = let (f, _, _, _, _) = accumTypes checkTypeVars in f d
78+ checkTypeVarsInDecl :: S.Set String -> Declaration -> MultipleErrors
79+ checkTypeVarsInDecl s d = let (f, _, _, _, _) = accumTypes (checkTypeVars s) in f d
7580
76− checkTypeVars :: Type -> MultipleErrors
77− checkTypeVars ty = everythingWithContextOnTypes S.empty mempty mappend step ty <> findUnused ty
81+ checkTypeVars :: S.Set String -> Type -> MultipleErrors
82+ checkTypeVars set ty = everythingWithContextOnTypes set mempty mappend step ty <> findUnused ty
7883 where
7984 step :: S.Set String -> Type -> (S.Set String, MultipleErrors)
8085 step s (ForAll tv _ _) = bindVar s tv