@@ -24,6 +24,7 @@ import Language.PureScript.Crash
24import Language.PureScript.Kinds
24import Language.PureScript.Kinds
25import Language.PureScript.Names
25import Language.PureScript.Names
26import Language.PureScript.Pretty
26import Language.PureScript.Pretty
27+import Language.PureScript.Traversals
27import Language.PureScript.Types
28import Language.PureScript.Types
28import qualified Language.PureScript.Bundle as Bundle
29import qualified Language.PureScript.Bundle as Bundle
29import qualified Language.PureScript.Constants as C
30import qualified Language.PureScript.Constants as C
@@ -112,7 +113,7 @@ data SimpleErrorMessage
112 | ShadowedTypeVar String
113 | ShadowedTypeVar String
113 | UnusedTypeVar String
114 | UnusedTypeVar String
114 | WildcardInferredType Type
115 | WildcardInferredType Type
115− | HoleInferredType String Type
116+ | HoleInferredType String Type [(Ident, Type)]
116 | MissingTypeDeclaration Ident Type
117 | MissingTypeDeclaration Ident Type
117 | OverlappingPattern [[Binder]] Bool
118 | OverlappingPattern [[Binder]] Bool
118 | IncompleteExhaustivityCheck
119 | IncompleteExhaustivityCheck
@@ -395,7 +396,7 @@ onTypesInErrorMessageM f (ErrorMessage hints simple) = ErrorMessage <$> traverse
395 gSimple (ExpectedType ty k) = ExpectedType <$> f ty <*> pure k
396 gSimple (ExpectedType ty k) = ExpectedType <$> f ty <*> pure k
396 gSimple (OrphanInstance nm cl ts) = OrphanInstance nm cl <$> traverse f ts
397 gSimple (OrphanInstance nm cl ts) = OrphanInstance nm cl <$> traverse f ts
397 gSimple (WildcardInferredType ty) = WildcardInferredType <$> f ty
398 gSimple (WildcardInferredType ty) = WildcardInferredType <$> f ty
398− gSimple (HoleInferredType name ty) = HoleInferredType name <$> f ty
399+ gSimple (HoleInferredType name ty env) = HoleInferredType name <$> f ty <*> traverse (sndM f) env
399 gSimple (MissingTypeDeclaration nm ty) = MissingTypeDeclaration nm <$> f ty
400 gSimple (MissingTypeDeclaration nm ty) = MissingTypeDeclaration nm <$> f ty
400 gSimple (CannotGeneralizeRecursiveFunction nm ty) = CannotGeneralizeRecursiveFunction nm <$> f ty
401 gSimple (CannotGeneralizeRecursiveFunction nm ty) = CannotGeneralizeRecursiveFunction nm <$> f ty
@@ -494,7 +495,7 @@ prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap
494 : foldMap (return . line . (" bound at " ++) . displayStartEndPos) ss
495 : foldMap (return . line . (" bound at " ++) . displayStartEndPos) ss
496 unknownInfo :: Int -> Box.Box
497 unknownInfo :: Int -> Box.Box
497− unknownInfo u = line $ "_" ++ show u ++ " is an unknown type"
498+ unknownInfo u = line $ "t" ++ show u ++ " is an unknown type"
499 renderSimpleErrorMessage :: SimpleErrorMessage -> Box.Box
500 renderSimpleErrorMessage :: SimpleErrorMessage -> Box.Box
500 renderSimpleErrorMessage (CannotGetFileInfo path) =
501 renderSimpleErrorMessage (CannotGetFileInfo path) =
@@ -817,10 +818,20 @@ prettyPrintSingleError full level showWiki e = flip evalState defaultUnknownMap
817 paras [ line "Wildcard type definition has the inferred type "
818 paras [ line "Wildcard type definition has the inferred type "
818 , indent $ typeAsBox ty
819 , indent $ typeAsBox ty
820− renderSimpleErrorMessage (HoleInferredType name ty) =
821+ renderSimpleErrorMessage (HoleInferredType name ty env) =
821− paras [ line $ "Hole '" ++ name ++ "' has the inferred type "
822+ paras $ [ line $ "Hole '" ++ name ++ "' has the inferred type "
822− , indent $ typeAsBox ty
823+ , indent $ typeAsBox ty
824+ ] ++ if null env then [] else envInfo
826+ envInfo :: [Box.Box]
827+ envInfo = [ line "in the following context:"
829+ [ Box.hcat Box.left [ Box.text (showIdent ident <> " :: ")
832+ | (ident, ty') <- take 5 env
824 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
835 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
825 paras [ line $ "No type declaration was provided for the top-level declaration of " ++ showIdent ident ++ "."
836 paras [ line $ "No type declaration was provided for the top-level declaration of " ++ showIdent ident ++ "."
826 , line "It is good practice to provide type declarations as a form of documentation."
837 , line "It is good practice to provide type declarations as a form of documentation."