@@ -41,8 +41,8 @@ import Control.Applicative ((<$>), (<*>), Applicative, pure)
41import Control.Monad.Trans.State.Lazy
41import Control.Monad.Trans.State.Lazy
42import Control.Arrow(first)
42import Control.Arrow(first)
44+import Language.PureScript.Crash
44import Language.PureScript.AST
45import Language.PureScript.AST
45−import Language.PureScript.Environment (isObject, isFunction)
46import Language.PureScript.Pretty
46import Language.PureScript.Pretty
47import Language.PureScript.Types
47import Language.PureScript.Types
48import Language.PureScript.Names
48import Language.PureScript.Names
@@ -62,13 +62,11 @@ data SimpleErrorMessage
62 | MissingFFIModule ModuleName
62 | MissingFFIModule ModuleName
63 | MultipleFFIModules ModuleName [FilePath]
63 | MultipleFFIModules ModuleName [FilePath]
64 | UnnecessaryFFIModule ModuleName FilePath
64 | UnnecessaryFFIModule ModuleName FilePath
65− | InvalidExternsFile FilePath
66 | CannotGetFileInfo FilePath
65 | CannotGetFileInfo FilePath
67 | CannotReadFile FilePath
66 | CannotReadFile FilePath
68 | CannotWriteFile FilePath
67 | CannotWriteFile FilePath
69 | InfiniteType Type
68 | InfiniteType Type
70 | InfiniteKind Kind
69 | InfiniteKind Kind
71− | CannotReorderOperators
72 | MultipleFixities Ident
70 | MultipleFixities Ident
73 | OrphanTypeDeclaration Ident
71 | OrphanTypeDeclaration Ident
74 | OrphanFixityDeclaration String
72 | OrphanFixityDeclaration String
@@ -108,11 +106,9 @@ data SimpleErrorMessage
108 | CycleInTypeSynonym (Maybe ProperName)
106 | CycleInTypeSynonym (Maybe ProperName)
109 | CycleInModules [ModuleName]
107 | CycleInModules [ModuleName]
110 | NameIsUndefined Ident
108 | NameIsUndefined Ident
111− | NameNotInScope Ident
112 | UndefinedTypeVariable ProperName
109 | UndefinedTypeVariable ProperName
113 | PartiallyAppliedSynonym (Qualified ProperName)
110 | PartiallyAppliedSynonym (Qualified ProperName)
114 | EscapedSkolem (Maybe Expr)
111 | EscapedSkolem (Maybe Expr)
115− | UnspecifiedSkolemScope
116 | TypesDoNotUnify Type Type
112 | TypesDoNotUnify Type Type
117 | KindsDoNotUnify Kind Kind
113 | KindsDoNotUnify Kind Kind
118 | ConstrainedTypeUnified Type Type
114 | ConstrainedTypeUnified Type Type
@@ -126,16 +122,15 @@ data SimpleErrorMessage
126 | ArgListLengthsDiffer Ident
122 | ArgListLengthsDiffer Ident
127 | OverlappingArgNames (Maybe Ident)
123 | OverlappingArgNames (Maybe Ident)
128 | MissingClassMember Ident
124 | MissingClassMember Ident
129− | ExtraneousClassMember Ident
125+ | ExtraneousClassMember Ident (Qualified ProperName)
130 | ExpectedType Type Kind
126 | ExpectedType Type Kind
131 | IncorrectConstructorArity (Qualified ProperName)
127 | IncorrectConstructorArity (Qualified ProperName)
132− | SubsumptionCheckFailed
133 | ExprDoesNotHaveType Expr Type
128 | ExprDoesNotHaveType Expr Type
134 | PropertyIsMissing String Type
129 | PropertyIsMissing String Type
135 | CannotApplyFunction Type Expr
130 | CannotApplyFunction Type Expr
136 | TypeSynonymInstance
131 | TypeSynonymInstance
137 | OrphanInstance Ident (Qualified ProperName) [Type]
132 | OrphanInstance Ident (Qualified ProperName) [Type]
138− | InvalidNewtype
133+ | InvalidNewtype ProperName
139 | InvalidInstanceHead Type
134 | InvalidInstanceHead Type
140 | TransitiveExportError DeclarationRef [DeclarationRef]
135 | TransitiveExportError DeclarationRef [DeclarationRef]
141 | ShadowedName Ident
136 | ShadowedName Ident
@@ -202,13 +197,11 @@ errorCode em = case unwrapErrorMessage em of
202 MissingFFIModule{} -> "MissingFFIModule"
197 MissingFFIModule{} -> "MissingFFIModule"
203 MultipleFFIModules{} -> "MultipleFFIModules"
198 MultipleFFIModules{} -> "MultipleFFIModules"
204 UnnecessaryFFIModule{} -> "UnnecessaryFFIModule"
199 UnnecessaryFFIModule{} -> "UnnecessaryFFIModule"
205− InvalidExternsFile{} -> "InvalidExternsFile"
206 CannotGetFileInfo{} -> "CannotGetFileInfo"
200 CannotGetFileInfo{} -> "CannotGetFileInfo"
207 CannotReadFile{} -> "CannotReadFile"
201 CannotReadFile{} -> "CannotReadFile"
208 CannotWriteFile{} -> "CannotWriteFile"
202 CannotWriteFile{} -> "CannotWriteFile"
209 InfiniteType{} -> "InfiniteType"
203 InfiniteType{} -> "InfiniteType"
210 InfiniteKind{} -> "InfiniteKind"
204 InfiniteKind{} -> "InfiniteKind"
211− CannotReorderOperators -> "CannotReorderOperators"
212 MultipleFixities{} -> "MultipleFixities"
205 MultipleFixities{} -> "MultipleFixities"
213 OrphanTypeDeclaration{} -> "OrphanTypeDeclaration"
206 OrphanTypeDeclaration{} -> "OrphanTypeDeclaration"
214 OrphanFixityDeclaration{} -> "OrphanFixityDeclaration"
207 OrphanFixityDeclaration{} -> "OrphanFixityDeclaration"
@@ -248,11 +241,9 @@ errorCode em = case unwrapErrorMessage em of
248 CycleInTypeSynonym{} -> "CycleInTypeSynonym"
241 CycleInTypeSynonym{} -> "CycleInTypeSynonym"
249 CycleInModules{} -> "CycleInModules"
242 CycleInModules{} -> "CycleInModules"
250 NameIsUndefined{} -> "NameIsUndefined"
243 NameIsUndefined{} -> "NameIsUndefined"
251− NameNotInScope{} -> "NameNotInScope"
252 UndefinedTypeVariable{} -> "UndefinedTypeVariable"
244 UndefinedTypeVariable{} -> "UndefinedTypeVariable"
253 PartiallyAppliedSynonym{} -> "PartiallyAppliedSynonym"
245 PartiallyAppliedSynonym{} -> "PartiallyAppliedSynonym"
254 EscapedSkolem{} -> "EscapedSkolem"
246 EscapedSkolem{} -> "EscapedSkolem"
255− UnspecifiedSkolemScope -> "UnspecifiedSkolemScope"
256 TypesDoNotUnify{} -> "TypesDoNotUnify"
247 TypesDoNotUnify{} -> "TypesDoNotUnify"
257 KindsDoNotUnify{} -> "KindsDoNotUnify"
248 KindsDoNotUnify{} -> "KindsDoNotUnify"
258 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
249 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
@@ -269,13 +260,12 @@ errorCode em = case unwrapErrorMessage em of
269 ExtraneousClassMember{} -> "ExtraneousClassMember"
260 ExtraneousClassMember{} -> "ExtraneousClassMember"
270 ExpectedType{} -> "ExpectedType"
261 ExpectedType{} -> "ExpectedType"
271 IncorrectConstructorArity{} -> "IncorrectConstructorArity"
262 IncorrectConstructorArity{} -> "IncorrectConstructorArity"
272− SubsumptionCheckFailed -> "SubsumptionCheckFailed"
273 ExprDoesNotHaveType{} -> "ExprDoesNotHaveType"
263 ExprDoesNotHaveType{} -> "ExprDoesNotHaveType"
274 PropertyIsMissing{} -> "PropertyIsMissing"
264 PropertyIsMissing{} -> "PropertyIsMissing"
275 CannotApplyFunction{} -> "CannotApplyFunction"
265 CannotApplyFunction{} -> "CannotApplyFunction"
276 TypeSynonymInstance -> "TypeSynonymInstance"
266 TypeSynonymInstance -> "TypeSynonymInstance"
277 OrphanInstance{} -> "OrphanInstance"
267 OrphanInstance{} -> "OrphanInstance"
278− InvalidNewtype -> "InvalidNewtype"
268+ InvalidNewtype{} -> "InvalidNewtype"
279 InvalidInstanceHead{} -> "InvalidInstanceHead"
269 InvalidInstanceHead{} -> "InvalidInstanceHead"
280 TransitiveExportError{} -> "TransitiveExportError"
270 TransitiveExportError{} -> "TransitiveExportError"
281 ShadowedName{} -> "ShadowedName"
271 ShadowedName{} -> "ShadowedName"
@@ -385,9 +375,9 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
385 prettyPrintErrorMessage (ErrorMessage hints simple) =
375 prettyPrintErrorMessage (ErrorMessage hints simple) =
387 map renderHint hints ++
377 map renderHint hints ++
388− renderSimpleErrorMessage simple :
378+ [ renderSimpleErrorMessage simple
389− suggestions simple ++
390− [line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."]
379+ , line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."
392 wikiUri :: String
382 wikiUri :: String
393 wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
383 wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
@@ -410,7 +400,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
410 , prettyPrintParseError err
400 , prettyPrintParseError err
412 renderSimpleErrorMessage (ErrorParsingFFIModule path) =
402 renderSimpleErrorMessage (ErrorParsingFFIModule path) =
413− paras [ line "Unable to parse module from FFI file: "
403+ paras [ line "Unable to parse foreign module:"
414 , indent . line $ path
404 , indent . line $ path
416 renderSimpleErrorMessage (ErrorParsingModule err) =
406 renderSimpleErrorMessage (ErrorParsingModule err) =
@@ -418,29 +408,22 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
418 , prettyPrintParseError err
408 , prettyPrintParseError err
420 renderSimpleErrorMessage (MissingFFIModule mn) =
410 renderSimpleErrorMessage (MissingFFIModule mn) =
421− line $ "Missing FFI implementations for module " ++ runModuleName mn
411+ line $ "The foreign module implementation for module " ++ runModuleName mn ++ " is missing."
422 renderSimpleErrorMessage (UnnecessaryFFIModule mn path) =
412 renderSimpleErrorMessage (UnnecessaryFFIModule mn path) =
423− paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ runModuleName mn ++ ": "
413+ paras [ line $ "An unnecessary foreign module implementation was provided for module " ++ runModuleName mn ++ ": "
424 , indent . line $ path
414 , indent . line $ path
415+ , line $ "Module " ++ runModuleName mn ++ " does not contain any foreign import declarations, so a foreign module is not necessary."
426 renderSimpleErrorMessage (MultipleFFIModules mn paths) =
417 renderSimpleErrorMessage (MultipleFFIModules mn paths) =
427− paras [ line $ "Multiple FFI implementations have been provided for module " ++ runModuleName mn ++ ": "
418+ paras [ line $ "Multiple foreign module implementations have been provided for module " ++ runModuleName mn ++ ": "
428 , indent . paras $ map line paths
419 , indent . paras $ map line paths
430− renderSimpleErrorMessage (InvalidExternsFile path) =
431− paras [ line "Externs file is invalid: "
432− , indent . line $ path
434 renderSimpleErrorMessage InvalidDoBind =
421 renderSimpleErrorMessage InvalidDoBind =
435− line "Bind statement cannot be the last statement in a do block. The last statement must be an expression."
422+ line "The last statement in a 'do' block must be an expression, but this block ends with a binder."
436 renderSimpleErrorMessage InvalidDoLet =
423 renderSimpleErrorMessage InvalidDoLet =
437− line "Let statement cannot be the last statement in a do block. The last statement must be an expression."
424+ line "The last statement in a 'do' block must be an expression, but this block ends with a let binding."
438− renderSimpleErrorMessage CannotReorderOperators =
439− line "Unable to reorder operators"
440− renderSimpleErrorMessage UnspecifiedSkolemScope =
441− line "Skolem variable scope is unspecified"
442 renderSimpleErrorMessage OverlappingNamesInLet =
425 renderSimpleErrorMessage OverlappingNamesInLet =
443− line "Overlapping names in let binding."
426+ line "The same name was used more than once in a let binding."
444 renderSimpleErrorMessage (InfiniteType ty) =
427 renderSimpleErrorMessage (InfiniteType ty) =
445 paras [ line "An infinite type was inferred for an expression: "
428 paras [ line "An infinite type was inferred for an expression: "
446 , indent $ typeAsBox ty
429 , indent $ typeAsBox ty
@@ -450,17 +433,17 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
450 , indent $ line $ prettyPrintKind ki
433 , indent $ line $ prettyPrintKind ki
452 renderSimpleErrorMessage (MultipleFixities name) =
435 renderSimpleErrorMessage (MultipleFixities name) =
453− line $ "Multiple fixity declarations for " ++ showIdent name
436+ line $ "There are multiple fixity/precedence declarations for " ++ showIdent name
454 renderSimpleErrorMessage (OrphanTypeDeclaration nm) =
437 renderSimpleErrorMessage (OrphanTypeDeclaration nm) =
455− line $ "Orphan type declaration for " ++ showIdent nm
438+ line $ "The type declaration for " ++ showIdent nm ++ " should be followed by its definition."
456 renderSimpleErrorMessage (OrphanFixityDeclaration op) =
439 renderSimpleErrorMessage (OrphanFixityDeclaration op) =
457− line $ "Orphan fixity declaration for " ++ show op
440+ line $ "The fixity/precedence declaration for " ++ show op ++ " should appear in the same module as its definition."
458 renderSimpleErrorMessage (RedefinedModule name filenames) =
441 renderSimpleErrorMessage (RedefinedModule name filenames) =
459− paras [ line ("Module " ++ runModuleName name ++ " has been defined multiple times:")
442+ paras [ line ("The module " ++ runModuleName name ++ " has been defined multiple times:")
460 , indent . paras $ map (line . displaySourceSpan) filenames
443 , indent . paras $ map (line . displaySourceSpan) filenames
462 renderSimpleErrorMessage (RedefinedIdent name) =
445 renderSimpleErrorMessage (RedefinedIdent name) =
463− line $ "Name " ++ showIdent name ++ " has been defined multiple times"
446+ line $ "The value " ++ showIdent name ++ " has been defined multiple times"
464 renderSimpleErrorMessage (UnknownModule mn) =
447 renderSimpleErrorMessage (UnknownModule mn) =
465 line $ "Unknown module " ++ runModuleName mn
448 line $ "Unknown module " ++ runModuleName mn
466 renderSimpleErrorMessage (UnknownType name) =
449 renderSimpleErrorMessage (UnknownType name) =
@@ -474,25 +457,36 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
474 renderSimpleErrorMessage (UnknownDataConstructor dc tc) =
457 renderSimpleErrorMessage (UnknownDataConstructor dc tc) =
475 line $ "Unknown data constructor " ++ showQualified runProperName dc ++ foldMap ((" for type constructor " ++) . showQualified runProperName) tc
458 line $ "Unknown data constructor " ++ showQualified runProperName dc ++ foldMap ((" for type constructor " ++) . showQualified runProperName) tc
476 renderSimpleErrorMessage (UnknownImportType mn name) =
459 renderSimpleErrorMessage (UnknownImportType mn name) =
477− line $ "Module " ++ runModuleName mn ++ " does not export type " ++ runProperName name
460+ paras [ line $ "Cannot import type " ++ runProperName name ++ " from module " ++ runModuleName mn
461+ , line "It either does not exist or the module does not export it."
478 renderSimpleErrorMessage (UnknownExportType name) =
463 renderSimpleErrorMessage (UnknownExportType name) =
479 line $ "Cannot export unknown type " ++ runProperName name
464 line $ "Cannot export unknown type " ++ runProperName name
480 renderSimpleErrorMessage (UnknownImportTypeClass mn name) =
465 renderSimpleErrorMessage (UnknownImportTypeClass mn name) =
481− line $ "Module " ++ runModuleName mn ++ " does not export type class " ++ runProperName name
466+ paras [ line $ "Cannot import type class " ++ runProperName name ++ " from module " ++ runModuleName mn
467+ , line "It either does not exist or the module does not export it."
482 renderSimpleErrorMessage (UnknownExportTypeClass name) =
469 renderSimpleErrorMessage (UnknownExportTypeClass name) =
483 line $ "Cannot export unknown type class " ++ runProperName name
470 line $ "Cannot export unknown type class " ++ runProperName name
484 renderSimpleErrorMessage (UnknownImportValue mn name) =
471 renderSimpleErrorMessage (UnknownImportValue mn name) =
485− line $ "Module " ++ runModuleName mn ++ " does not export value " ++ showIdent name
472+ paras [ line $ "Cannot import value " ++ showIdent name ++ " from module " ++ runModuleName mn
473+ , line "It either does not exist or the module does not export it."
486 renderSimpleErrorMessage (UnknownExportValue name) =
475 renderSimpleErrorMessage (UnknownExportValue name) =
487 line $ "Cannot export unknown value " ++ showIdent name
476 line $ "Cannot export unknown value " ++ showIdent name
488 renderSimpleErrorMessage (UnknownExportModule name) =
477 renderSimpleErrorMessage (UnknownExportModule name) =
478+ paras [ line $ "Cannot export unknown module " ++ runModuleName name
489− line $ "Cannot export unknown module " ++ runModuleName name ++ ", it either does not exist or has not been imported by the current module"
479+ , line "It either does not exist or has not been imported by the current module."
490 renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
481 renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
491 line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon
482 line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon
492 renderSimpleErrorMessage (UnknownExportDataConstructor tcon dcon) =
483 renderSimpleErrorMessage (UnknownExportDataConstructor tcon dcon) =
493− line $ "Cannot export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon ++ " as it has not been declared"
484+ line $ "Cannot export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon ++ ", as it has not been declared."
494 renderSimpleErrorMessage (ConflictingImport nm mn) =
485 renderSimpleErrorMessage (ConflictingImport nm mn) =
495− line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ runModuleName mn
486+ paras [ line $ "Cannot declare " ++ show nm ++ ", since another declaration of that name was imported from module " ++ runModuleName mn
487+ , line $ "Consider hiding " ++ show nm ++ " when importing " ++ runModuleName mn ++ ":"
488+ , indent . line $ "import " ++ runModuleName mn ++ " hiding (" ++ nm ++ ")"
496 renderSimpleErrorMessage (ConflictingImports nm m1 m2) =
490 renderSimpleErrorMessage (ConflictingImports nm m1 m2) =
497 line $ "Conflicting imports for " ++ nm ++ " from modules " ++ runModuleName m1 ++ " and " ++ runModuleName m2
491 line $ "Conflicting imports for " ++ nm ++ " from modules " ++ runModuleName m1 ++ " and " ++ runModuleName m2
498 renderSimpleErrorMessage (ConflictingTypeDecls nm) =
492 renderSimpleErrorMessage (ConflictingTypeDecls nm) =
@@ -500,13 +494,13 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
500 renderSimpleErrorMessage (ConflictingCtorDecls nm) =
494 renderSimpleErrorMessage (ConflictingCtorDecls nm) =
501 line $ "Conflicting data constructor declarations for " ++ runProperName nm
495 line $ "Conflicting data constructor declarations for " ++ runProperName nm
502 renderSimpleErrorMessage (TypeConflictsWithClass nm) =
496 renderSimpleErrorMessage (TypeConflictsWithClass nm) =
503− line $ "Type " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
497+ line $ "Type " ++ runProperName nm ++ " conflicts with a type class declaration with the same name."
504 renderSimpleErrorMessage (CtorConflictsWithClass nm) =
498 renderSimpleErrorMessage (CtorConflictsWithClass nm) =
505− line $ "Data constructor " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
499+ line $ "Data constructor " ++ runProperName nm ++ " conflicts with a type class declaration with the same name."
506 renderSimpleErrorMessage (ClassConflictsWithType nm) =
500 renderSimpleErrorMessage (ClassConflictsWithType nm) =
507− line $ "Type class " ++ runProperName nm ++ " conflicts with type declaration of the same name"
501+ line $ "Type class " ++ runProperName nm ++ " conflicts with a type declaration with the same name."
508 renderSimpleErrorMessage (ClassConflictsWithCtor nm) =
502 renderSimpleErrorMessage (ClassConflictsWithCtor nm) =
509− line $ "Type class " ++ runProperName nm ++ " conflicts with data constructor declaration of the same name"
503+ line $ "Type class " ++ runProperName nm ++ " conflicts with a data constructor declaration with the same name."
510 renderSimpleErrorMessage (DuplicateModuleName mn) =
504 renderSimpleErrorMessage (DuplicateModuleName mn) =
511 line $ "Module " ++ runModuleName mn ++ " has been defined multiple times."
505 line $ "Module " ++ runModuleName mn ++ " has been defined multiple times."
512 renderSimpleErrorMessage (DuplicateClassExport nm) =
506 renderSimpleErrorMessage (DuplicateClassExport nm) =
@@ -514,19 +508,24 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
514 renderSimpleErrorMessage (DuplicateValueExport nm) =
508 renderSimpleErrorMessage (DuplicateValueExport nm) =
515 line $ "Duplicate export declaration for value " ++ showIdent nm
509 line $ "Duplicate export declaration for value " ++ showIdent nm
516 renderSimpleErrorMessage (CycleInDeclaration nm) =
510 renderSimpleErrorMessage (CycleInDeclaration nm) =
517− line $ "Cycle in declaration of " ++ showIdent nm
511+ line $ "The value of " ++ showIdent nm ++ " is undefined here, so this reference is not allowed."
518 renderSimpleErrorMessage (CycleInModules mns) =
512 renderSimpleErrorMessage (CycleInModules mns) =
519− line $ "Cycle in module dependencies: " ++ intercalate ", " (map runModuleName mns)
513+ paras [ line $ "There is a cycle in module dependencies in these modules: "
514+ , indent $ paras (map (line . runModuleName) mns)
520− renderSimpleErrorMessage (CycleInTypeSynonym pn) =
516+ renderSimpleErrorMessage (CycleInTypeSynonym name) =
521− line $ "Cycle in type synonym" ++ foldMap ((" " ++) . runProperName) pn
517+ paras [ line $ case name of
518+ Just pn -> "A cycle appears in the definition of type synonym " ++ runProperName pn
519+ Nothing -> "A cycle appears in a set of type synonym definitions."
520+ , line "Cycles are disallowed because they can lead to loops in the type checker."
521+ , line "Consider using a 'newtype' instead."
522 renderSimpleErrorMessage (NameIsUndefined ident) =
523 renderSimpleErrorMessage (NameIsUndefined ident) =
523− line $ showIdent ident ++ " is undefined"
524+ line $ "Value " ++ showIdent ident ++ " is undefined."
524− renderSimpleErrorMessage (NameNotInScope ident) =
525− line $ showIdent ident ++ " may not be defined in the current scope"
526 renderSimpleErrorMessage (UndefinedTypeVariable name) =
525 renderSimpleErrorMessage (UndefinedTypeVariable name) =
527− line $ "Type variable " ++ runProperName name ++ " is undefined"
526+ line $ "Type variable " ++ runProperName name ++ " is undefined."
528 renderSimpleErrorMessage (PartiallyAppliedSynonym name) =
527 renderSimpleErrorMessage (PartiallyAppliedSynonym name) =
529− paras [ line $ "Partially applied type synonym " ++ showQualified runProperName name
528+ paras [ line $ "Type synonym " ++ showQualified runProperName name ++ " is partially applied."
530 , line "Type synonyms must be applied to all of their type arguments."
529 , line "Type synonyms must be applied to all of their type arguments."
532 renderSimpleErrorMessage (EscapedSkolem binding) =
531 renderSimpleErrorMessage (EscapedSkolem binding) =
@@ -535,70 +534,72 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
535 , indent $ prettyPrintValue expr
534 , indent $ prettyPrintValue expr
536 ]) binding
535 ]) binding
537 renderSimpleErrorMessage (TypesDoNotUnify t1 t2)
536 renderSimpleErrorMessage (TypesDoNotUnify t1 t2)
538− = paras [ line "Cannot unify type"
537+ = paras [ line "Could not match expected type"
539 , indent $ typeAsBox t1
538 , indent $ typeAsBox t1
540− , line "with type"
539+ , line "with actual type"
541 , indent $ typeAsBox t2
540 , indent $ typeAsBox t2
543 renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
542 renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
544− paras [ line "Cannot unify kind"
543+ paras [ line "Could not match expected kind"
545 , indent $ line $ prettyPrintKind k1
544 , indent $ line $ prettyPrintKind k1
546− , line "with kind"
545+ , line "with actual kind"
547 , indent $ line $ prettyPrintKind k2
546 , indent $ line $ prettyPrintKind k2
549 renderSimpleErrorMessage (ConstrainedTypeUnified t1 t2) =
548 renderSimpleErrorMessage (ConstrainedTypeUnified t1 t2) =
550− paras [ line "Cannot unify constrained type"
549+ paras [ line "Could not match constrained type"
551 , indent $ typeAsBox t1
550 , indent $ typeAsBox t1
552 , line "with type"
551 , line "with type"
553 , indent $ typeAsBox t2
552 , indent $ typeAsBox t2
555 renderSimpleErrorMessage (OverlappingInstances nm ts (d : ds)) =
554 renderSimpleErrorMessage (OverlappingInstances nm ts (d : ds)) =
556− paras [ line "Overlapping instances found for"
555+ paras [ line "Overlapping type class instances found for"
557 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
556 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
558 , Box.vcat Box.left (map typeAtomAsBox ts)
557 , Box.vcat Box.left (map typeAtomAsBox ts)
560 , line "The following instances were found:"
559 , line "The following instances were found:"
561 , indent $ paras (line (showQualified showIdent d ++ " (chosen)") : map (line . showQualified showIdent) ds)
560 , indent $ paras (line (showQualified showIdent d ++ " (chosen)") : map (line . showQualified showIdent) ds)
561+ , line "Overlapping type class instances can lead to different behavior based on the order of module imports, and for that reason are not recommended."
562+ , line "They may be disallowed completely in a future version of the compiler."
563− renderSimpleErrorMessage OverlappingInstances{} = error "OverlappingInstances: empty instance list"
564+ renderSimpleErrorMessage OverlappingInstances{} = internalError "OverlappingInstances: empty instance list"
564 renderSimpleErrorMessage (NoInstanceFound nm ts) =
565 renderSimpleErrorMessage (NoInstanceFound nm ts) =
565− paras [ line "No instance found for"
566+ paras [ line "No type class instance was found for"
566 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
567 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
567 , Box.vcat Box.left (map typeAtomAsBox ts)
568 , Box.vcat Box.left (map typeAtomAsBox ts)
570 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
571 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
571− paras [ line "Instance for"
572+ paras [ line "Type class instance for"
572 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
573 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
573 , Box.vcat Box.left (map typeAtomAsBox ts)
574 , Box.vcat Box.left (map typeAtomAsBox ts)
575 , line "is possibly infinite."
576 , line "is possibly infinite."
577 renderSimpleErrorMessage (CannotDerive nm ts) =
578 renderSimpleErrorMessage (CannotDerive nm ts) =
578− paras [ line "Cannot derive an instance for"
579+ paras [ line "Cannot derive a type class instance for"
579 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
580 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
580 , Box.vcat Box.left (map typeAtomAsBox ts)
581 , Box.vcat Box.left (map typeAtomAsBox ts)
583 renderSimpleErrorMessage (CannotFindDerivingType nm) =
584 renderSimpleErrorMessage (CannotFindDerivingType nm) =
584− line $ "Cannot derive instance, because the type declaration for " ++ runProperName nm ++ " could not be found."
585+ line $ "Cannot derive a type class instance, because the type declaration for " ++ runProperName nm ++ " could not be found."
585 renderSimpleErrorMessage (DuplicateLabel l expr) =
586 renderSimpleErrorMessage (DuplicateLabel l expr) =
586− paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
587+ paras $ [ line $ "Label " ++ show l ++ " appears more than once in a row type." ]
587 <> foldMap (\expr' -> [ line "Relevant expression: "
588 <> foldMap (\expr' -> [ line "Relevant expression: "
588 , indent $ prettyPrintValue expr'
589 , indent $ prettyPrintValue expr'
590 renderSimpleErrorMessage (DuplicateTypeArgument name) =
591 renderSimpleErrorMessage (DuplicateTypeArgument name) =
591− line $ "Duplicate type argument " ++ show name
592+ line $ "Type argument " ++ show name ++ " appears more than once."
592 renderSimpleErrorMessage (DuplicateValueDeclaration nm) =
593 renderSimpleErrorMessage (DuplicateValueDeclaration nm) =
593− line $ "Duplicate value declaration for " ++ showIdent nm
594+ line $ "Multiple value declarations exist for " ++ showIdent nm ++ "."
594 renderSimpleErrorMessage (ArgListLengthsDiffer ident) =
595 renderSimpleErrorMessage (ArgListLengthsDiffer ident) =
595 line $ "Argument list lengths differ in declaration " ++ showIdent ident
596 line $ "Argument list lengths differ in declaration " ++ showIdent ident
596 renderSimpleErrorMessage (OverlappingArgNames ident) =
597 renderSimpleErrorMessage (OverlappingArgNames ident) =
597 line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . showIdent) ident
598 line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . showIdent) ident
598 renderSimpleErrorMessage (MissingClassMember ident) =
599 renderSimpleErrorMessage (MissingClassMember ident) =
599− line $ "Member " ++ showIdent ident ++ " has not been implemented"
600+ line $ "Type class member " ++ showIdent ident ++ " has not been implemented."
600− renderSimpleErrorMessage (ExtraneousClassMember ident) =
601+ renderSimpleErrorMessage (ExtraneousClassMember ident className) =
601− line $ "Member " ++ showIdent ident ++ " is not a member of the class being instantiated"
602+ line $ showIdent ident ++ " is not a member of type class " ++ showQualified runProperName className
602 renderSimpleErrorMessage (ExpectedType ty kind) =
603 renderSimpleErrorMessage (ExpectedType ty kind) =
603 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
604 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
604 , line "The error arises from the type"
605 , line "The error arises from the type"
@@ -608,8 +609,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
608 , line "instead."
609 , line "instead."
610 renderSimpleErrorMessage (IncorrectConstructorArity nm) =
611 renderSimpleErrorMessage (IncorrectConstructorArity nm) =
611− line $ "Wrong number of arguments to constructor " ++ showQualified runProperName nm
612+ line $ "Data constructor " ++ showQualified runProperName nm ++ " was given the wrong number of arguments in a case expression."
612− renderSimpleErrorMessage SubsumptionCheckFailed = line "Unable to check type subsumption"
613 renderSimpleErrorMessage (ExprDoesNotHaveType expr ty) =
613 renderSimpleErrorMessage (ExprDoesNotHaveType expr ty) =
614 paras [ line "Expression"
614 paras [ line "Expression"
615 , indent $ prettyPrintValue expr
615 , indent $ prettyPrintValue expr
@@ -617,20 +617,20 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
617 , indent $ typeAsBox ty
617 , indent $ typeAsBox ty
619 renderSimpleErrorMessage (PropertyIsMissing prop row) =
619 renderSimpleErrorMessage (PropertyIsMissing prop row) =
620− paras [ line "Row"
620+ paras [ line "Row type"
621 , indent $ prettyPrintRowWith '(' ')' row
621 , indent $ prettyPrintRowWith '(' ')' row
622− , line $ "lacks required property " ++ show prop
622+ , line $ "lacks required label " ++ show prop
624 renderSimpleErrorMessage (CannotApplyFunction fn arg) =
624 renderSimpleErrorMessage (CannotApplyFunction fn arg) =
625− paras [ line "Cannot apply function of type"
625+ paras [ line "A function of type"
626 , indent $ typeAsBox fn
626 , indent $ typeAsBox fn
627− , line "to argument"
627+ , line "can not be applied to the argument"
628 , indent $ prettyPrintValue arg
628 , indent $ prettyPrintValue arg
630 renderSimpleErrorMessage TypeSynonymInstance =
630 renderSimpleErrorMessage TypeSynonymInstance =
631− line "Type synonym instances are disallowed"
631+ line "Type class instances for type synonyms are disallowed."
632 renderSimpleErrorMessage (OrphanInstance nm cnm ts) =
632 renderSimpleErrorMessage (OrphanInstance nm cnm ts) =
633− paras [ line $ "Instance " ++ showIdent nm ++ " for "
633+ paras [ line $ "Type class instance " ++ showIdent nm ++ " for "
634 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName cnm)
634 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName cnm)
635 , Box.vcat Box.left (map typeAtomAsBox ts)
635 , Box.vcat Box.left (map typeAtomAsBox ts)
@@ -638,32 +638,37 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
638 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
638 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
639 , line "Consider moving the instance, if possible, or using a newtype wrapper."
639 , line "Consider moving the instance, if possible, or using a newtype wrapper."
641− renderSimpleErrorMessage InvalidNewtype =
641+ renderSimpleErrorMessage (InvalidNewtype name) =
642+ paras [ line $ "Newtype " ++ runProperName name ++ " is invalid."
642− line "Newtypes must define a single constructor with a single argument"
643+ , line "Newtypes must define a single constructor with a single argument."
643 renderSimpleErrorMessage (InvalidInstanceHead ty) =
645 renderSimpleErrorMessage (InvalidInstanceHead ty) =
644− paras [ line "Invalid type in class instance head:"
646+ paras [ line "Type class instance head is invalid due to use of type"
645 , indent $ typeAsBox ty
647 , indent $ typeAsBox ty
648+ , line "All types appearing in instance declarations must be of the form T a_1 .. a_n, where each type a_i is of the same form."
647 renderSimpleErrorMessage (TransitiveExportError x ys) =
650 renderSimpleErrorMessage (TransitiveExportError x ys) =
648 paras $ line ("An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
651 paras $ line ("An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
649 : map (line . prettyPrintExport) ys
652 : map (line . prettyPrintExport) ys
650 renderSimpleErrorMessage (ShadowedName nm) =
653 renderSimpleErrorMessage (ShadowedName nm) =
651− line $ "Name '" ++ showIdent nm ++ "' was shadowed"
654+ line $ "Name '" ++ showIdent nm ++ "' was shadowed."
652 renderSimpleErrorMessage (ShadowedTypeVar tv) =
655 renderSimpleErrorMessage (ShadowedTypeVar tv) =
653− line $ "Type variable '" ++ tv ++ "' was shadowed"
656+ line $ "Type variable '" ++ tv ++ "' was shadowed."
654 renderSimpleErrorMessage (UnusedTypeVar tv) =
657 renderSimpleErrorMessage (UnusedTypeVar tv) =
655− line $ "Type variable '" ++ tv ++ "' was declared but not used"
658+ line $ "Type variable '" ++ tv ++ "' was declared but not used."
656 renderSimpleErrorMessage (ClassOperator className opName) =
659 renderSimpleErrorMessage (ClassOperator className opName) =
657− paras [ line $ "Class '" ++ runProperName className ++ "' declares operator " ++ showIdent opName ++ "."
660+ paras [ line $ "Type class '" ++ runProperName className ++ "' declares operator " ++ showIdent opName ++ "."
658 , line "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
661 , line "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
659 , indent . line $ showIdent opName ++ " = someMember"
662 , indent . line $ showIdent opName ++ " = someMember"
661 renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
664 renderSimpleErrorMessage (MisleadingEmptyTypeImport mn name) =
662− line $ "Importing type " ++ runProperName name ++ "(..) from " ++ runModuleName mn ++ " is misleading as it has no exported data constructors"
665+ line $ "Importing type " ++ runProperName name ++ "(..) from " ++ runModuleName mn ++ " is misleading as it has no exported data constructors."
663 renderSimpleErrorMessage (ImportHidingModule name) =
666 renderSimpleErrorMessage (ImportHidingModule name) =
667+ paras [ line $ "'hiding' imports cannot be used to hide modules."
664− line $ "Attempted to hide module " ++ runModuleName name ++ " in import expression, this is not permitted"
668+ , line $ "An attempt was made to hide the import of " ++ runModuleName name
665 renderSimpleErrorMessage (WildcardInferredType ty) =
670 renderSimpleErrorMessage (WildcardInferredType ty) =
666− paras [ line "The wildcard type definition has the inferred type "
671+ paras [ line "Wildcard type definition has the inferred type "
667 , indent $ typeAsBox ty
672 , indent $ typeAsBox ty
669 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
674 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
@@ -692,7 +697,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
692 renderHint (NotYetDefined names) =
697 renderHint (NotYetDefined names) =
693 line $ "The following are not yet defined here: " ++ intercalate ", " (map showIdent names) ++ ":"
698 line $ "The following are not yet defined here: " ++ intercalate ", " (map showIdent names) ++ ":"
694 renderHint (ErrorUnifyingTypes t1 t2) =
699 renderHint (ErrorUnifyingTypes t1 t2) =
695− paras [ lineWithLevel "unifying type "
700+ paras [ lineWithLevel "while trying to match type "
696 , indent $ typeAsBox t1
701 , indent $ typeAsBox t1
697 , line "with type"
702 , line "with type"
698 , indent $ typeAsBox t2
703 , indent $ typeAsBox t2
@@ -705,9 +710,9 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
705 paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
710 paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
707 renderHint (ErrorInSubsumption t1 t2) =
712 renderHint (ErrorInSubsumption t1 t2) =
708− paras [ lineWithLevel "checking that type "
713+ paras [ lineWithLevel "checking that type"
709 , indent $ typeAsBox t1
714 , indent $ typeAsBox t1
710− , line "subsumes type"
715+ , line "is at least as general as type"
711 , indent $ typeAsBox t2
716 , indent $ typeAsBox t2
713 renderHint (ErrorInInstance nm ts) =
718 renderHint (ErrorInInstance nm ts) =
@@ -717,21 +722,21 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
719 renderHint (ErrorCheckingKind ty) =
724 renderHint (ErrorCheckingKind ty) =
720− paras [ lineWithLevel "checking kind of type "
725+ paras [ lineWithLevel "checking kind of type"
721 , indent $ typeAsBox ty
726 , indent $ typeAsBox ty
723 renderHint (ErrorInferringType expr) =
728 renderHint (ErrorInferringType expr) =
724− paras [ lineWithLevel "inferring type of value "
729+ paras [ lineWithLevel "inferring type of expression"
725 , indent $ prettyPrintValue expr
730 , indent $ prettyPrintValue expr
727 renderHint (ErrorCheckingType expr ty) =
732 renderHint (ErrorCheckingType expr ty) =
728− paras [ lineWithLevel "checking that value "
733+ paras [ lineWithLevel "checking that expression"
729 , indent $ prettyPrintValue expr
734 , indent $ prettyPrintValue expr
730 , line "has type"
735 , line "has type"
731 , indent $ typeAsBox ty
736 , indent $ typeAsBox ty
733 renderHint (ErrorInApplication f t a) =
738 renderHint (ErrorInApplication f t a) =
734− paras [ lineWithLevel "applying function"
739+ paras [ lineWithLevel "applying a function"
735 , indent $ prettyPrintValue f
740 , indent $ prettyPrintValue f
736 , line "of type"
741 , line "of type"
737 , indent $ typeAsBox t
742 , indent $ typeAsBox t
@@ -765,15 +770,6 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
765 Error -> "error"
770 Error -> "error"
766 Warning -> "warning"
771 Warning -> "warning"
768− suggestions :: SimpleErrorMessage -> [Box.Box]
769− suggestions (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ runModuleName im ++ ":"
770− , indent . line $ "import " ++ runModuleName im ++ " hiding (" ++ nm ++ ")"
772− suggestions (TypesDoNotUnify t1 t2)
773− | isObject t1 && isFunction t2 = [line "Note that function composition in PureScript is defined using (<<<)"]
777 paras :: [Box.Box] -> Box.Box
773 paras :: [Box.Box] -> Box.Box
778 paras = Box.vcat Box.left
774 paras = Box.vcat Box.left