@@ -118,6 +118,7 @@ errorCode em = case unwrapErrorMessage em of
118118 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
119119 OverlappingInstances{} -> "OverlappingInstances"
120120 NoInstanceFound{} -> "NoInstanceFound"
121+ AmbiguousTypeVariables{} -> "AmbiguousTypeVariables"
121122 UnknownClass{} -> "UnknownClass"
122123 PossiblyInfiniteInstance{} -> "PossiblyInfiniteInstance"
123124 CannotDerive{} -> "CannotDerive"
@@ -261,6 +262,7 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
261262 gSimple (ExprDoesNotHaveType e t) = ExprDoesNotHaveType e <$> f t
262263 gSimple (InvalidInstanceHead t) = InvalidInstanceHead <$> f t
263264 gSimple (NoInstanceFound con) = NoInstanceFound <$> overConstraintArgs (traverse f) con
265+ gSimple (AmbiguousTypeVariables t con) = AmbiguousTypeVariables <$> (f t) <*> pure con
264266 gSimple (OverlappingInstances cl ts insts) = OverlappingInstances cl <$> traverse f ts <*> pure insts
265267 gSimple (PossiblyInfiniteInstance cl ts) = PossiblyInfiniteInstance cl <$> traverse f ts
266268 gSimple (CannotDerive cl ts) = CannotDerive cl <$> traverse f ts
@@ -636,6 +638,11 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
636638 where
637639 go TUnknown{} = True
638640 go _ = False
641+ renderSimpleErrorMessage (AmbiguousTypeVariables t _) =
642+ paras [ line "The inferred type"
643+ , indent $ line $ markCode $ prettyPrintType t
644+ , line "has type variables which are not mentioned in the body of the type. Consider adding a type annotation."
645+ ]
639646 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
640647 paras [ line "Type class instance for"
641648 , markCodeBox $ indent $ Box.hsep 1 Box.left