@@ -51,7 +51,11 @@ import qualified Text.Parsec as P
52data SimpleErrorMessage
52data SimpleErrorMessage
53 = ErrorParsingExterns P.ParseError
53 = ErrorParsingExterns P.ParseError
54− | ErrorParsingPrelude P.ParseError
54+ | ErrorParsingFFIModule FilePath
55+ | ErrorParsingModule P.ParseError
56+ | MissingFFIModule ModuleName
57+ | MultipleFFIModules ModuleName [FilePath]
58+ | UnnecessaryFFIModule ModuleName FilePath
55 | InvalidExternsFile FilePath
59 | InvalidExternsFile FilePath
56 | CannotGetFileInfo FilePath
60 | CannotGetFileInfo FilePath
57 | CannotReadFile FilePath
61 | CannotReadFile FilePath
@@ -115,13 +119,12 @@ data SimpleErrorMessage
115 | TransitiveExportError DeclarationRef [DeclarationRef]
119 | TransitiveExportError DeclarationRef [DeclarationRef]
116 | ShadowedName Ident
120 | ShadowedName Ident
117 | WildcardInferredType Type
121 | WildcardInferredType Type
119 deriving (Show)
122 deriving (Show)
122-- Wrapper of simpler errors
125-- Wrapper of simpler errors
124−data ErrorMessage
127+data ErrorMessage
125 = NotYetDefined [Ident] ErrorMessage
128 = NotYetDefined [Ident] ErrorMessage
126 | ErrorUnifyingTypes Type Type ErrorMessage
129 | ErrorUnifyingTypes Type Type ErrorMessage
127 | ErrorInExpression Expr ErrorMessage
130 | ErrorInExpression Expr ErrorMessage
@@ -142,10 +145,10 @@ data ErrorMessage
142 | PositionedError SourceSpan ErrorMessage
145 | PositionedError SourceSpan ErrorMessage
143 | SimpleErrorWrapper SimpleErrorMessage
146 | SimpleErrorWrapper SimpleErrorMessage
144 deriving (Show)
147 deriving (Show)
146instance UnificationError Type ErrorMessage where
149instance UnificationError Type ErrorMessage where
147 occursCheckFailed t = SimpleErrorWrapper $ InfiniteType t
150 occursCheckFailed t = SimpleErrorWrapper $ InfiniteType t
149instance UnificationError Kind ErrorMessage where
152instance UnificationError Kind ErrorMessage where
150 occursCheckFailed k = SimpleErrorWrapper $ InfiniteKind k
153 occursCheckFailed k = SimpleErrorWrapper $ InfiniteKind k
@@ -155,7 +158,11 @@ instance UnificationError Kind ErrorMessage where
155errorCode :: ErrorMessage -> String
158errorCode :: ErrorMessage -> String
156errorCode em = case unwrapErrorMessage em of
159errorCode em = case unwrapErrorMessage em of
157 (ErrorParsingExterns _) -> "ErrorParsingExterns"
160 (ErrorParsingExterns _) -> "ErrorParsingExterns"
158− (ErrorParsingPrelude _) -> "ErrorParsingPrelude"
161+ (ErrorParsingFFIModule _) -> "ErrorParsingFFIModule"
162+ (ErrorParsingModule _) -> "ErrorParsingModule"
163+ MissingFFIModule{} -> "MissingFFIModule"
164+ MultipleFFIModules{} -> "MultipleFFIModules"
165+ UnnecessaryFFIModule{} -> "UnnecessaryFFIModule"
159 (InvalidExternsFile _) -> "InvalidExternsFile"
166 (InvalidExternsFile _) -> "InvalidExternsFile"
160 (CannotGetFileInfo _) -> "CannotGetFileInfo"
167 (CannotGetFileInfo _) -> "CannotGetFileInfo"
161 (CannotReadFile _) -> "CannotReadFile"
168 (CannotReadFile _) -> "CannotReadFile"
@@ -219,17 +226,16 @@ errorCode em = case unwrapErrorMessage em of
219 (TransitiveExportError _ _) -> "TransitiveExportError"
226 (TransitiveExportError _ _) -> "TransitiveExportError"
220 (ShadowedName _) -> "ShadowedName"
227 (ShadowedName _) -> "ShadowedName"
221 (WildcardInferredType _) -> "WildcardInferredType"
228 (WildcardInferredType _) -> "WildcardInferredType"
222− PreludeNotPresent -> "PreludeNotPresent"
225-- A stack trace for an error
231-- A stack trace for an error
227−newtype MultipleErrors = MultipleErrors
233+newtype MultipleErrors = MultipleErrors
228 { runMultipleErrors :: [ErrorMessage] } deriving (Show, Monoid)
234 { runMultipleErrors :: [ErrorMessage] } deriving (Show, Monoid)
230instance UnificationError Type MultipleErrors where
236instance UnificationError Type MultipleErrors where
231 occursCheckFailed = occursCheckFailed
237 occursCheckFailed = occursCheckFailed
233instance UnificationError Kind MultipleErrors where
239instance UnificationError Kind MultipleErrors where
234 occursCheckFailed = occursCheckFailed
240 occursCheckFailed = occursCheckFailed
@@ -288,7 +294,7 @@ unwrapErrorMessage em = case em of
288 (SimpleErrorWrapper sem) -> sem
294 (SimpleErrorWrapper sem) -> sem
290replaceUnknowns :: Type -> State UnknownMap Type
296replaceUnknowns :: Type -> State UnknownMap Type
291−replaceUnknowns = everywhereOnTypesM replaceTypes
297+replaceUnknowns = everywhereOnTypesM replaceTypes
293 lookupTable :: (LabelType, Unknown) -> UnknownMap -> (Unknown, UnknownMap)
299 lookupTable :: (LabelType, Unknown) -> UnknownMap -> (Unknown, UnknownMap)
294 lookupTable x m = case M.lookup x m of
300 lookupTable x m = case M.lookup x m of
@@ -348,195 +354,287 @@ prettyPrintSingleError full e = prettyPrintErrorMessage <$> onTypesInErrorMessag
349 wikiUri :: String
355 wikiUri :: String
350 wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
356 wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
352 go :: ErrorMessage -> Box.Box
358 go :: ErrorMessage -> Box.Box
353− goSimple (CannotGetFileInfo path) = paras [ line "Unable to read file info: "
359+ goSimple (CannotGetFileInfo path) =
360+ paras [ line "Unable to read file info: "
354− , indent . line $ path
361+ , indent . line $ path
356− goSimple (CannotReadFile path) = paras [ line "Unable to read file: "
363+ goSimple (CannotReadFile path) =
364+ paras [ line "Unable to read file: "
357− , indent . line $ path
365+ , indent . line $ path
359− goSimple (CannotWriteFile path) = paras [ line "Unable to write file: "
367+ goSimple (CannotWriteFile path) =
368+ paras [ line "Unable to write file: "
360− , indent . line $ path
369+ , indent . line $ path
371+ goSimple (ErrorParsingExterns err) =
362− goSimple (ErrorParsingExterns err) = paras [ line "Error parsing externs files: "
372+ paras [ line "Error parsing externs files: "
363− , indent . line . show $ err
373+ , indent . line . show $ err
375+ goSimple (ErrorParsingFFIModule path) =
376+ paras [ line "Unable to parse module from FFI file: "
377+ , indent . line $ path
365− goSimple (ErrorParsingPrelude err) = paras [ line "Error parsing prelude: "
379+ goSimple (ErrorParsingModule err) =
380+ paras [ line "Unable to parse module: "
366− , indent . line . show $ err
381+ , indent . line . show $ err
383+ goSimple (MissingFFIModule mn) =
384+ line $ "Missing FFI implementations for module " ++ show mn
385+ goSimple (UnnecessaryFFIModule mn path) =
386+ paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ show mn ++ ": "
387+ , indent . line $ path
389+ goSimple (MultipleFFIModules mn paths) =
390+ paras $ [ line $ "Multiple FFI implementations have been provided for module " ++ show mn ++ ": " ]
391+ ++ map (indent . line) paths
392+ goSimple (InvalidExternsFile path) =
368− goSimple (InvalidExternsFile path) = paras [ line "Externs file is invalid: "
393+ paras [ line "Externs file is invalid: "
369− , indent . line $ path
394+ , indent . line $ path
396+ goSimple InvalidDoBind =
371− goSimple InvalidDoBind = line "Bind statement cannot be the last statement in a do block"
397+ line "Bind statement cannot be the last statement in a do block"
398+ goSimple InvalidDoLet =
372− goSimple InvalidDoLet = line "Let statement cannot be the last statement in a do block"
399+ line "Let statement cannot be the last statement in a do block"
373− goSimple CannotReorderOperators = line "Unable to reorder operators"
400+ goSimple CannotReorderOperators =
401+ line "Unable to reorder operators"
402+ goSimple UnspecifiedSkolemScope =
374− goSimple UnspecifiedSkolemScope = line "Skolem variable scope is unspecified"
403+ line "Skolem variable scope is unspecified"
404+ goSimple OverlappingNamesInLet =
375− goSimple OverlappingNamesInLet = line "Overlapping names in let binding."
405+ line "Overlapping names in let binding."
406+ goSimple (InfiniteType ty) =
376− goSimple (InfiniteType ty) = paras [ line "Infinite type detected: "
407+ paras [ line "Infinite type detected: "
377− , indent $ line $ prettyPrintType ty
408+ , indent $ line $ prettyPrintType ty
410+ goSimple (InfiniteKind ki) =
379− goSimple (InfiniteKind ki) = paras [ line "Infinite kind detected: "
411+ paras [ line "Infinite kind detected: "
380− , indent $ line $ prettyPrintKind ki
412+ , indent $ line $ prettyPrintKind ki
414+ goSimple (MultipleFixities name) =
382− goSimple (MultipleFixities name) = line $ "Multiple fixity declarations for " ++ show name
415+ line $ "Multiple fixity declarations for " ++ show name
416+ goSimple (OrphanTypeDeclaration nm) =
383− goSimple (OrphanTypeDeclaration nm) = line $ "Orphan type declaration for " ++ show nm
417+ line $ "Orphan type declaration for " ++ show nm
418+ goSimple (OrphanFixityDeclaration op) =
384− goSimple (OrphanFixityDeclaration op) = line $ "Orphan fixity declaration for " ++ show op
419+ line $ "Orphan fixity declaration for " ++ show op
420+ goSimple (RedefinedModule name) =
385− goSimple (RedefinedModule name) = line $ "Module " ++ show name ++ " has been defined multiple times"
421+ line $ "Module " ++ show name ++ " has been defined multiple times"
422+ goSimple (RedefinedIdent name) =
386− goSimple (RedefinedIdent name) = line $ "Name " ++ show name ++ " has been defined multiple times"
423+ line $ "Name " ++ show name ++ " has been defined multiple times"
387− goSimple (UnknownModule mn) = line $ "Unknown module " ++ show mn
424+ goSimple (UnknownModule mn) =
425+ line $ "Unknown module " ++ show mn
388− goSimple (UnknownType name) = line $ "Unknown type " ++ show name
426+ goSimple (UnknownType name) =
427+ line $ "Unknown type " ++ show name
389− goSimple (UnknownTypeClass name) = line $ "Unknown type class " ++ show name
428+ goSimple (UnknownTypeClass name) =
429+ line $ "Unknown type class " ++ show name
390− goSimple (UnknownValue name) = line $ "Unknown value " ++ show name
430+ goSimple (UnknownValue name) =
431+ line $ "Unknown value " ++ show name
391− goSimple (UnknownTypeConstructor name) = line $ "Unknown type constructor " ++ show name
432+ goSimple (UnknownTypeConstructor name) =
433+ line $ "Unknown type constructor " ++ show name
434+ goSimple (UnknownDataConstructor dc tc) =
392− goSimple (UnknownDataConstructor dc tc) = line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
435+ line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
436+ goSimple (ConflictingImport nm mn) =
393− goSimple (ConflictingImport nm mn) = line $ "Cannot declare `" ++ nm ++ "` since another declaration of that name was imported from `" ++ show mn ++ "`"
437+ line $ "Cannot declare `" ++ nm ++ "` since another declaration of that name was imported from `" ++ show mn ++ "`"
438+ goSimple (ConflictingImports nm m1 m2) =
394− goSimple (ConflictingImports nm m1 m2) = line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
439+ line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
440+ goSimple (ConflictingTypeDecls nm) =
395− goSimple (ConflictingTypeDecls nm) = line $ "Conflicting type declarations for " ++ show nm
441+ line $ "Conflicting type declarations for " ++ show nm
442+ goSimple (ConflictingCtorDecls nm) =
396− goSimple (ConflictingCtorDecls nm) = line $ "Conflicting data constructor declarations for " ++ show nm
443+ line $ "Conflicting data constructor declarations for " ++ show nm
444+ goSimple (TypeConflictsWithClass nm) =
397− goSimple (TypeConflictsWithClass nm) = line $ "Type " ++ show nm ++ " conflicts with type class declaration of the same name"
445+ line $ "Type " ++ show nm ++ " conflicts with type class declaration of the same name"
446+ goSimple (CtorConflictsWithClass nm) =
398− goSimple (CtorConflictsWithClass nm) = line $ "Data constructor " ++ show nm ++ " conflicts with type class declaration of the same name"
447+ line $ "Data constructor " ++ show nm ++ " conflicts with type class declaration of the same name"
448+ goSimple (ClassConflictsWithType nm) =
399− goSimple (ClassConflictsWithType nm) = line $ "Type class " ++ show nm ++ " conflicts with type declaration of the same name"
449+ line $ "Type class " ++ show nm ++ " conflicts with type declaration of the same name"
450+ goSimple (ClassConflictsWithCtor nm) =
400− goSimple (ClassConflictsWithCtor nm) = line $ "Type class " ++ show nm ++ " conflicts with data constructor declaration of the same name"
451+ line $ "Type class " ++ show nm ++ " conflicts with data constructor declaration of the same name"
452+ goSimple (DuplicateClassExport nm) =
401− goSimple (DuplicateClassExport nm) = line $ "Duplicate export declaration for type class " ++ show nm
453+ line $ "Duplicate export declaration for type class " ++ show nm
454+ goSimple (DuplicateValueExport nm) =
402− goSimple (DuplicateValueExport nm) = line $ "Duplicate export declaration for value " ++ show nm
455+ line $ "Duplicate export declaration for value " ++ show nm
456+ goSimple (CycleInDeclaration nm) =
403− goSimple (CycleInDeclaration nm) = line $ "Cycle in declaration of " ++ show nm
457+ line $ "Cycle in declaration of " ++ show nm
458+ goSimple (CycleInModules mns) =
404− goSimple (CycleInModules mns) = line $ "Cycle in module dependencies: " ++ intercalate ", " (map show mns)
459+ line $ "Cycle in module dependencies: " ++ intercalate ", " (map show mns)
460+ goSimple (CycleInTypeSynonym pn) =
405− goSimple (CycleInTypeSynonym pn) = line $ "Cycle in type synonym" ++ foldMap ((" " ++) . show) pn
461+ line $ "Cycle in type synonym" ++ foldMap ((" " ++) . show) pn
406− goSimple (NameIsUndefined ident) = line $ show ident ++ " is undefined"
462+ goSimple (NameIsUndefined ident) =
463+ line $ show ident ++ " is undefined"
464+ goSimple (NameNotInScope ident) =
407− goSimple (NameNotInScope ident) = line $ show ident ++ " may not be defined in the current scope"
465+ line $ show ident ++ " may not be defined in the current scope"
466+ goSimple (UndefinedTypeVariable name) =
408− goSimple (UndefinedTypeVariable name) = line $ "Type variable " ++ show name ++ " is undefined"
467+ line $ "Type variable " ++ show name ++ " is undefined"
468+ goSimple (PartiallyAppliedSynonym name) =
409− goSimple (PartiallyAppliedSynonym name) = line $ "Partially applied type synonym " ++ show name
469+ line $ "Partially applied type synonym " ++ show name
470+ goSimple (EscapedSkolem binding) =
410− goSimple (EscapedSkolem binding) = paras $ [ line "Rigid/skolem type variable has escaped." ]
471+ paras $ [ line "Rigid/skolem type variable has escaped." ]
411− <> foldMap (\expr -> [ line "Relevant expression: "
472+ <> foldMap (\expr -> [ line "Relevant expression: "
412− , indent $ line $ prettyPrintValue expr
473+ , indent $ line $ prettyPrintValue expr
413− ]) binding
474+ ]) binding
414− goSimple (TypesDoNotUnify t1 t2) = paras [ line "Cannot unify type"
475+ goSimple (TypesDoNotUnify t1 t2)
476+ = paras [ line "Cannot unify type"
415− , indent $ line $ prettyPrintType t1
477+ , indent $ line $ prettyPrintType t1
416− , line "with type"
478+ , line "with type"
417− , indent $ line $ prettyPrintType t2
479+ , indent $ line $ prettyPrintType t2
419− goSimple (KindsDoNotUnify k1 k2) = paras [ line "Cannot unify kind"
481+ goSimple (KindsDoNotUnify k1 k2) =
482+ paras [ line "Cannot unify kind"
420− , indent $ line $ prettyPrintKind k1
483+ , indent $ line $ prettyPrintKind k1
421− , line "with kind"
484+ , line "with kind"
422− , indent $ line $ prettyPrintKind k2
485+ , indent $ line $ prettyPrintKind k2
487+ goSimple (ConstrainedTypeUnified t1 t2) =
424− goSimple (ConstrainedTypeUnified t1 t2) = paras [ line "Cannot unify constrained type"
488+ paras [ line "Cannot unify constrained type"
425− , indent $ line $ prettyPrintType t1
489+ , indent $ line $ prettyPrintType t1
426− , line "with type"
490+ , line "with type"
427− , indent $ line $ prettyPrintType t2
491+ , indent $ line $ prettyPrintType t2
493+ goSimple (OverlappingInstances nm ts ds) =
429− goSimple (OverlappingInstances nm ts ds) = paras [ line $ "Overlapping instances found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
494+ paras [ line $ "Overlapping instances found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
430− , paras $ map prettyPrintDictionaryValue ds
495+ , paras $ map prettyPrintDictionaryValue ds
497+ goSimple (NoInstanceFound nm ts) =
432− goSimple (NoInstanceFound nm ts) = line $ "No instance found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
498+ line $ "No instance found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
499+ goSimple (DuplicateLabel l expr) =
433− goSimple (DuplicateLabel l expr) = paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
500+ paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
434− <> foldMap (\expr' -> [ line "Relevant expression: "
501+ <> foldMap (\expr' -> [ line "Relevant expression: "
435− , indent $ line $ prettyPrintValue expr'
502+ , indent $ line $ prettyPrintValue expr'
437− goSimple (DuplicateTypeArgument name) = line $ "Duplicate type argument " ++ show name
504+ goSimple (DuplicateTypeArgument name) =
505+ line $ "Duplicate type argument " ++ show name
506+ goSimple (DuplicateValueDeclaration nm) =
438− goSimple (DuplicateValueDeclaration nm) = line $ "Duplicate value declaration for " ++ show nm
507+ line $ "Duplicate value declaration for " ++ show nm
508+ goSimple (ArgListLengthsDiffer ident) =
439− goSimple (ArgListLengthsDiffer ident) = line $ "Argument list lengths differ in declaration " ++ show ident
509+ line $ "Argument list lengths differ in declaration " ++ show ident
510+ goSimple (OverlappingArgNames ident) =
440− goSimple (OverlappingArgNames ident) = line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . show) ident
511+ line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . show) ident
512+ goSimple (MissingClassMember ident) =
441− goSimple (MissingClassMember ident) = line $ "Member " ++ show ident ++ " has not been implemented"
513+ line $ "Member " ++ show ident ++ " has not been implemented"
514+ goSimple (ExpectedType kind) =
442− goSimple (ExpectedType kind) = line $ "Expected type of kind *, was " ++ prettyPrintKind kind
515+ line $ "Expected type of kind *, was " ++ prettyPrintKind kind
516+ goSimple (IncorrectConstructorArity nm) =
443− goSimple (IncorrectConstructorArity nm) = line $ "Wrong number of arguments to constructor " ++ show nm
517+ line $ "Wrong number of arguments to constructor " ++ show nm
444− goSimple SubsumptionCheckFailed = line $ "Unable to check type subsumption"
518+ goSimple SubsumptionCheckFailed = line $ "Unable to check type subsumption"
445− goSimple (ExprDoesNotHaveType expr ty) = paras [ line "Expression"
519+ goSimple (ExprDoesNotHaveType expr ty) =
520+ paras [ line "Expression"
446− , indent $ line $ prettyPrintValue expr
521+ , indent $ line $ prettyPrintValue expr
447− , line "does not have type"
522+ , line "does not have type"
448− , indent $ line $ prettyPrintType ty
523+ , indent $ line $ prettyPrintType ty
525+ goSimple (PropertyIsMissing prop row) =
450− goSimple (PropertyIsMissing prop row) = line $ "Row " ++ prettyPrintRow row ++ " lacks required property " ++ show prop
526+ line $ "Row " ++ prettyPrintRow row ++ " lacks required property " ++ show prop
527+ goSimple (CannotApplyFunction fn arg) =
451− goSimple (CannotApplyFunction fn arg) = paras [ line "Cannot apply function of type"
528+ paras [ line "Cannot apply function of type"
452− , indent $ line $ prettyPrintType fn
529+ , indent $ line $ prettyPrintType fn
453− , line "to argument"
530+ , line "to argument"
454− , indent $ line $ prettyPrintValue arg
531+ , indent $ line $ prettyPrintValue arg
533+ goSimple TypeSynonymInstance =
456− goSimple TypeSynonymInstance = line "Type synonym instances are disallowed"
534+ line "Type synonym instances are disallowed"
535+ goSimple InvalidNewtype =
457− goSimple InvalidNewtype = line "Newtypes must define a single constructor with a single argument"
536+ line "Newtypes must define a single constructor with a single argument"
537+ goSimple (InvalidInstanceHead ty) =
458− goSimple (InvalidInstanceHead ty) = paras [ line "Invalid type in class instance head:"
538+ paras [ line "Invalid type in class instance head:"
459− , indent $ line $ prettyPrintType ty
539+ , indent $ line $ prettyPrintType ty
541+ goSimple (TransitiveExportError x ys) =
461− goSimple (TransitiveExportError x ys) = paras $ (line $ "An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
542+ paras $ (line $ "An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
462− : map (line . prettyPrintExport) ys
543+ : map (line . prettyPrintExport) ys
544+ goSimple (ShadowedName nm) =
463− goSimple (ShadowedName nm) = line $ "Name '" ++ show nm ++ "' was shadowed."
545+ line $ "Name '" ++ show nm ++ "' was shadowed."
546+ goSimple (WildcardInferredType ty) =
464− goSimple (WildcardInferredType ty) = line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
547+ line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
465− goSimple PreludeNotPresent = paras [ line $ "There is no Prelude module loaded, and the --no-prelude option was not specified."
548+ go (NotYetDefined names err) =
466− , line $ "You probably need to install the Prelude and other dependencies using Bower."
468− go (NotYetDefined names err) = paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
549+ paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
469− , indent $ go err
550+ , indent $ go err
471− go (ErrorUnifyingTypes t1 t2 err) = paras [ line "Error unifying type "
552+ go (ErrorUnifyingTypes t1 t2 err) =
553+ paras [ line "Error unifying type "
472− , indent $ line $ prettyPrintType t1
554+ , indent $ line $ prettyPrintType t1
473− , line "with type"
555+ , line "with type"
474− , indent $ line $ prettyPrintType t2
556+ , indent $ line $ prettyPrintType t2
475− , go err
557+ , go err
477− go (ErrorInExpression expr err) = paras [ line "Error in expression:"
559+ go (ErrorInExpression expr err) =
560+ paras [ line "Error in expression:"
478− , indent $ line $ prettyPrintValue expr
561+ , indent $ line $ prettyPrintValue expr
479− , go err
562+ , go err
564+ go (ErrorInModule mn err) =
481− go (ErrorInModule mn err) = paras [ line $ "Error in module " ++ show mn ++ ":"
565+ paras [ line $ "Error in module " ++ show mn ++ ":"
482− , go err
566+ , go err
568+ go (ErrorInSubsumption t1 t2 err) =
484− go (ErrorInSubsumption t1 t2 err) = paras [ line "Error checking that type "
569+ paras [ line "Error checking that type "
485− , indent $ line $ prettyPrintType t1
570+ , indent $ line $ prettyPrintType t1
486− , line "subsumes type"
571+ , line "subsumes type"
487− , indent $ line $ prettyPrintType t2
572+ , indent $ line $ prettyPrintType t2
488− , go err
573+ , go err
575+ go (ErrorInInstance name ts err) =
490− go (ErrorInInstance name ts err) = paras [ line $ "Error in type class instance " ++ show name ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
576+ paras [ line $ "Error in type class instance " ++ show name ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
491− , go err
577+ , go err
579+ go (ErrorCheckingKind ty err) =
493− go (ErrorCheckingKind ty err) = paras [ line "Error checking kind of type "
580+ paras [ line "Error checking kind of type "
494− , indent $ line $ prettyPrintType ty
581+ , indent $ line $ prettyPrintType ty
495− , go err
582+ , go err
584+ go (ErrorInferringType expr err) =
497− go (ErrorInferringType expr err) = paras [ line "Error inferring type of value "
585+ paras [ line "Error inferring type of value "
498− , indent $ line $ prettyPrintValue expr
586+ , indent $ line $ prettyPrintValue expr
499− , go err
587+ , go err
589+ go (ErrorCheckingType expr ty err) =
501− go (ErrorCheckingType expr ty err) = paras [ line "Error checking that value "
590+ paras [ line "Error checking that value "
502− , indent $ line $ prettyPrintValue expr
591+ , indent $ line $ prettyPrintValue expr
503− , line "has type"
592+ , line "has type"
504− , indent $ line $ prettyPrintType ty
593+ , indent $ line $ prettyPrintType ty
505− , go err
594+ , go err
596+ go (ErrorInApplication f t a err) =
507− go (ErrorInApplication f t a err) = paras [ line "Error applying function"
597+ paras [ line "Error applying function"
508− , indent $ line $ prettyPrintValue f
598+ , indent $ line $ prettyPrintValue f
509− , line "of type"
599+ , line "of type"
510− , indent $ line $ prettyPrintType t
600+ , indent $ line $ prettyPrintType t
511− , line "to argument"
601+ , line "to argument"
512− , indent $ line $ prettyPrintValue a
602+ , indent $ line $ prettyPrintValue a
513− , go err
603+ , go err
605+ go (ErrorInDataConstructor nm err) =
515− go (ErrorInDataConstructor nm err) = paras [ line $ "Error in data constructor " ++ show nm ++ ":"
606+ paras [ line $ "Error in data constructor " ++ show nm ++ ":"
516− , go err
607+ , go err
609+ go (ErrorInTypeConstructor nm err) =
518− go (ErrorInTypeConstructor nm err) = paras [ line $ "Error in type constructor " ++ show nm ++ ":"
610+ paras [ line $ "Error in type constructor " ++ show nm ++ ":"
519− , go err
611+ , go err
613+ go (ErrorInBindingGroup nms err) =
521− go (ErrorInBindingGroup nms err) = paras [ line $ "Error in binding group " ++ intercalate ", " (map show nms) ++ ":"
614+ paras [ line $ "Error in binding group " ++ intercalate ", " (map show nms) ++ ":"
522− , go err
615+ , go err
617+ go (ErrorInDataBindingGroup err) =
524− go (ErrorInDataBindingGroup err) = paras [ line $ "Error in data binding group:"
618+ paras [ line $ "Error in data binding group:"
525− , go err
619+ , go err
621+ go (ErrorInTypeSynonym name err) =
527− go (ErrorInTypeSynonym name err) = paras [ line $ "Error in type synonym " ++ show name ++ ":"
622+ paras [ line $ "Error in type synonym " ++ show name ++ ":"
528− , go err
623+ , go err
625+ go (ErrorInValueDeclaration n err) =
530− go (ErrorInValueDeclaration n err) = paras [ line $ "Error in value declaration " ++ show n ++ ":"
626+ paras [ line $ "Error in value declaration " ++ show n ++ ":"
531− , go err
627+ , go err
629+ go (ErrorInForeignImport nm err) =
533− go (ErrorInForeignImport nm err) = paras [ line $ "Error in foreign import " ++ show nm ++ ":"
630+ paras [ line $ "Error in foreign import " ++ show nm ++ ":"
534− , go err
631+ , go err
633+ go (PositionedError srcSpan err) =
536− go (PositionedError srcSpan err) = paras [ line $ "Error at " ++ displaySourceSpan srcSpan ++ ":"
634+ paras [ line $ "Error at " ++ displaySourceSpan srcSpan ++ ":"
537− , indent $ go err
635+ , indent $ go err
539− go (SimpleErrorWrapper sem) = goSimple sem
637+ go (SimpleErrorWrapper sem) = goSimple sem
541 line :: String -> Box.Box
639 line :: String -> Box.Box
542 line = Box.text
640 line = Box.text
@@ -570,10 +668,10 @@ prettyPrintSingleError full e = prettyPrintErrorMessage <$> onTypesInErrorMessag
570 prettyPrintDictionaryValue (SubclassDictionaryValue sup nm _) = paras [ line $ (show nm) ++ " via superclass"
668 prettyPrintDictionaryValue (SubclassDictionaryValue sup nm _) = paras [ line $ (show nm) ++ " via superclass"
571 , indent $ prettyPrintDictionaryValue sup
669 , indent $ prettyPrintDictionaryValue sup
575 -- Pretty print and export declaration
673 -- Pretty print and export declaration
577 prettyPrintExport :: DeclarationRef -> String
675 prettyPrintExport :: DeclarationRef -> String
578 prettyPrintExport (TypeRef pn _) = show pn
676 prettyPrintExport (TypeRef pn _) = show pn
579 prettyPrintExport (ValueRef ident) = show ident
677 prettyPrintExport (ValueRef ident) = show ident