@@ -56,8 +56,7 @@ import Text.Parsec.Error (Message(..))
57-- | A type of error messages
57-- | A type of error messages
58data SimpleErrorMessage
58data SimpleErrorMessage
59− = ErrorParsingExterns P.ParseError
60− | ErrorParsingFFIModule FilePath
59+ = ErrorParsingFFIModule FilePath
61 | ErrorParsingModule P.ParseError
60 | ErrorParsingModule P.ParseError
62 | MissingFFIModule ModuleName
61 | MissingFFIModule ModuleName
63 | MultipleFFIModules ModuleName [FilePath]
62 | MultipleFFIModules ModuleName [FilePath]
@@ -148,8 +147,7 @@ data SimpleErrorMessage
149-- | Error message hints, providing more detailed information about failure.
148-- | Error message hints, providing more detailed information about failure.
150data ErrorMessageHint
149data ErrorMessageHint
151− = NotYetDefined [Ident]
152− | ErrorUnifyingTypes Type Type
150+ = ErrorUnifyingTypes Type Type
153 | ErrorInExpression Expr
151 | ErrorInExpression Expr
154 | ErrorInModule ModuleName
152 | ErrorInModule ModuleName
155 | ErrorInInstance (Qualified ProperName) [Type]
153 | ErrorInInstance (Qualified ProperName) [Type]
@@ -192,7 +190,6 @@ instance UnificationError Kind ErrorMessage where
193errorCode :: ErrorMessage -> String
191errorCode :: ErrorMessage -> String
194errorCode em = case unwrapErrorMessage em of
192errorCode em = case unwrapErrorMessage em of
195− ErrorParsingExterns{} -> "ErrorParsingExterns"
196 ErrorParsingFFIModule{} -> "ErrorParsingFFIModule"
193 ErrorParsingFFIModule{} -> "ErrorParsingFFIModule"
197 ErrorParsingModule{} -> "ErrorParsingModule"
194 ErrorParsingModule{} -> "ErrorParsingModule"
198 MissingFFIModule{} -> "MissingFFIModule"
195 MissingFFIModule{} -> "MissingFFIModule"
@@ -375,9 +372,10 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
375 prettyPrintErrorMessage :: ErrorMessage -> Box.Box
372 prettyPrintErrorMessage :: ErrorMessage -> Box.Box
376 prettyPrintErrorMessage (ErrorMessage hints simple) =
373 prettyPrintErrorMessage (ErrorMessage hints simple) =
378− map renderHint hints ++
379− [ renderSimpleErrorMessage simple
375+ [ foldr renderHint (indent (renderSimpleErrorMessage simple)) hints
376+ , Box.moveDown 1 $ paras [ line $ "See " ++ wikiUri ++ " for more information, "
380− , line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."
377+ , line $ "or to contribute content related to this " ++ levelText ++ "."
383 wikiUri :: String
381 wikiUri :: String
@@ -396,10 +394,6 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
396 paras [ line "Unable to write file: "
394 paras [ line "Unable to write file: "
397 , indent . line $ path
395 , indent . line $ path
399− renderSimpleErrorMessage (ErrorParsingExterns err) =
400− paras [ lineWithLevel "parsing externs files: "
401− , prettyPrintParseError err
403 renderSimpleErrorMessage (ErrorParsingFFIModule path) =
397 renderSimpleErrorMessage (ErrorParsingFFIModule path) =
404 paras [ line "Unable to parse foreign module:"
398 paras [ line "Unable to parse foreign module:"
405 , indent . line $ path
399 , indent . line $ path
@@ -694,81 +688,117 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
694 , line "You may want to decompose your data types into smaller types."
688 , line "You may want to decompose your data types into smaller types."
697− renderHint :: ErrorMessageHint -> Box.Box
691+ renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
698− renderHint (NotYetDefined names) =
699− line $ "The following are not yet defined here: " ++ intercalate ", " (map showIdent names) ++ ":"
700− renderHint (ErrorUnifyingTypes t1 t2) =
692+ renderHint (ErrorUnifyingTypes t1 t2) detail =
701− paras [ lineWithLevel "while trying to match type "
694+ , Box.hsep 1 Box.top [ line "while trying to match type"
702− , indent $ typeAsBox t1
695+ , typeAsBox t1
703− , line "with type"
697+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "with type"
704− , indent $ typeAsBox t2
698+ , typeAsBox t2
706− renderHint (ErrorInExpression expr) =
701+ renderHint (ErrorInExpression expr) detail =
707− paras [ lineWithLevel "in expression:"
702+ paras [ detail
703+ , Box.hsep 1 Box.top [ Box.text "in the expression"
708− , indent $ prettyPrintValue expr
704+ , prettyPrintValue expr
710− renderHint (ErrorInModule mn) =
707+ renderHint (ErrorInModule mn) detail =
711− paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
708+ paras [ line $ "in module " ++ runModuleName mn
713− renderHint (ErrorInSubsumption t1 t2) =
711+ renderHint (ErrorInSubsumption t1 t2) detail =
714− paras [ lineWithLevel "checking that type"
713+ , Box.hsep 1 Box.top [ line "while checking that type"
715− , indent $ typeAsBox t1
714+ , typeAsBox t1
716− , line "is at least as general as type"
716+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "is at least as general as type"
717− , indent $ typeAsBox t2
717+ , typeAsBox t2
719− renderHint (ErrorInInstance nm ts) =
720+ renderHint (ErrorInInstance nm ts) detail =
720− paras [ lineWithLevel "in type class instance"
722+ , Box.hsep 1 Box.top [ line "in type class instance"
721− , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
723+ , line (showQualified runProperName nm)
722− , Box.vcat Box.left (map typeAtomAsBox ts)
724+ , Box.vcat Box.left (map typeAtomAsBox ts)
725− renderHint (ErrorCheckingKind ty) =
727+ renderHint (ErrorCheckingKind ty) detail =
726− paras [ lineWithLevel "checking kind of type"
728+ paras [ detail
729+ , Box.hsep 1 Box.top [ line "while checking the kind of"
727− , indent $ typeAsBox ty
730+ , typeAsBox ty
729− renderHint (ErrorInferringType expr) =
733+ renderHint (ErrorInferringType expr) detail =
730− paras [ lineWithLevel "inferring type of expression"
734+ paras [ detail
735+ , Box.hsep 1 Box.top [ line "while inferring the type of"
731− , indent $ prettyPrintValue expr
736+ , prettyPrintValue expr
733− renderHint (ErrorCheckingType expr ty) =
739+ renderHint (ErrorCheckingType expr ty) detail =
734− paras [ lineWithLevel "checking that expression"
741+ , Box.hsep 1 Box.top [ line "while checking that expression"
735− , indent $ prettyPrintValue expr
742+ , prettyPrintValue expr
736− , line "has type"
744+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "has type"
748+ renderHint (ErrorCheckingAccessor expr prop) detail =
750+ , Box.hsep 1 Box.top [ line "while checking type of property accessor"
751+ , prettyPrintValue (Accessor prop expr)
754+ renderHint (ErrorInApplication f t a) detail =
756+ , Box.hsep 1 Box.top [ line "while applying a function"
757+ , prettyPrintValue f
759+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "of type"
737− , indent $ typeAsBox ty
760+ , typeAsBox t
762+ , Box.moveRight 2 $ Box.hsep 1 Box.top [ line "to argument"
763+ , prettyPrintValue a
766+ renderHint (ErrorInDataConstructor nm) detail =
768+ , line $ "in data constructor " ++ runProperName nm
770+ renderHint (ErrorInTypeConstructor nm) detail =
772+ , line $ "in type constructor " ++ runProperName nm
774+ renderHint (ErrorInBindingGroup nms) detail =
776+ , line $ "in binding group " ++ intercalate ", " (map showIdent nms)
778+ renderHint ErrorInDataBindingGroup detail =
780+ , line "in data binding group"
782+ renderHint (ErrorInTypeSynonym name) detail =
784+ , line $ "in type synonym " ++ runProperName name
786+ renderHint (ErrorInValueDeclaration n) detail =
788+ , line $ "in value declaration " ++ showIdent n
790+ renderHint (ErrorInTypeDeclaration n) detail =
792+ , line $ "in type declaration for " ++ showIdent n
794+ renderHint (ErrorInForeignImport nm) detail =
796+ , line $ "in foreign import " ++ showIdent nm
798+ renderHint (PositionedError srcSpan) detail =
799+ paras [ line $ "at " ++ displaySourceSpan srcSpan
739− renderHint (ErrorCheckingAccessor expr prop) =
740− paras [ lineWithLevel "checking type of property accessor"
741− , indent $ prettyPrintValue (Accessor prop expr)
743− renderHint (ErrorInApplication f t a) =
744− paras [ lineWithLevel "applying a function"
745− , indent $ prettyPrintValue f
747− , indent $ typeAsBox t
748− , line "to argument"
749− , indent $ prettyPrintValue a
751− renderHint (ErrorInDataConstructor nm) =
752− lineWithLevel $ "in data constructor " ++ runProperName nm ++ ":"
753− renderHint (ErrorInTypeConstructor nm) =
754− lineWithLevel $ "in type constructor " ++ runProperName nm ++ ":"
755− renderHint (ErrorInBindingGroup nms) =
756− lineWithLevel $ "in binding group " ++ intercalate ", " (map showIdent nms) ++ ":"
757− renderHint ErrorInDataBindingGroup =
758− lineWithLevel "in data binding group:"
759− renderHint (ErrorInTypeSynonym name) =
760− lineWithLevel $ "in type synonym " ++ runProperName name ++ ":"
761− renderHint (ErrorInValueDeclaration n) =
762− lineWithLevel $ "in value declaration " ++ showIdent n ++ ":"
763− renderHint (ErrorInTypeDeclaration n) =
764− lineWithLevel $ "in type declaration for " ++ showIdent n ++ ":"
765− renderHint (ErrorInForeignImport nm) =
766− lineWithLevel $ "in foreign import " ++ showIdent nm ++ ":"
767− renderHint (PositionedError srcSpan) =
768− lineWithLevel $ "at " ++ displaySourceSpan srcSpan ++ ":"
770− lineWithLevel :: String -> Box.Box
771− lineWithLevel text = line $ show level ++ " " ++ text
773 levelText :: String
803 levelText :: String
774 levelText = case level of
804 levelText = case level of