@@ -118,6 +118,7 @@ errorCode em = case unwrapErrorMessage em of
118 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
118 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
119 OverlappingInstances{} -> "OverlappingInstances"
119 OverlappingInstances{} -> "OverlappingInstances"
120 NoInstanceFound{} -> "NoInstanceFound"
120 NoInstanceFound{} -> "NoInstanceFound"
121+ AmbiguousTypeVariables{} -> "AmbiguousTypeVariables"
121 UnknownClass{} -> "UnknownClass"
122 UnknownClass{} -> "UnknownClass"
122 PossiblyInfiniteInstance{} -> "PossiblyInfiniteInstance"
123 PossiblyInfiniteInstance{} -> "PossiblyInfiniteInstance"
123 CannotDerive{} -> "CannotDerive"
124 CannotDerive{} -> "CannotDerive"
@@ -261,6 +262,7 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
261 gSimple (ExprDoesNotHaveType e t) = ExprDoesNotHaveType e <$> f t
262 gSimple (ExprDoesNotHaveType e t) = ExprDoesNotHaveType e <$> f t
262 gSimple (InvalidInstanceHead t) = InvalidInstanceHead <$> f t
263 gSimple (InvalidInstanceHead t) = InvalidInstanceHead <$> f t
263 gSimple (NoInstanceFound con) = NoInstanceFound <$> overConstraintArgs (traverse f) con
264 gSimple (NoInstanceFound con) = NoInstanceFound <$> overConstraintArgs (traverse f) con
265+ gSimple (AmbiguousTypeVariables t con) = AmbiguousTypeVariables <$> (f t) <*> pure con
264 gSimple (OverlappingInstances cl ts insts) = OverlappingInstances cl <$> traverse f ts <*> pure insts
266 gSimple (OverlappingInstances cl ts insts) = OverlappingInstances cl <$> traverse f ts <*> pure insts
265 gSimple (PossiblyInfiniteInstance cl ts) = PossiblyInfiniteInstance cl <$> traverse f ts
267 gSimple (PossiblyInfiniteInstance cl ts) = PossiblyInfiniteInstance cl <$> traverse f ts
266 gSimple (CannotDerive cl ts) = CannotDerive cl <$> traverse f ts
268 gSimple (CannotDerive cl ts) = CannotDerive cl <$> traverse f ts
@@ -636,6 +638,11 @@ prettyPrintSingleError (PPEOptions codeColor full level showWiki) e = flip evalS
637 go TUnknown{} = True
639 go TUnknown{} = True
638 go _ = False
640 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."
639 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
646 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
640 paras [ line "Type class instance for"
647 paras [ line "Type class instance for"
641 , markCodeBox $ indent $ Box.hsep 1 Box.left
648 , markCodeBox $ indent $ Box.hsep 1 Box.left