@@ -41,8 +41,8 @@ import Control.Applicative ((<$>), (<*>), Applicative, pure)
4141import Control.Monad.Trans.State.Lazy
4242import Control.Arrow(first)
4343
44+import Language.PureScript.Crash
4445import Language.PureScript.AST
45−import Language.PureScript.Environment (isObject, isFunction)
4646import Language.PureScript.Pretty
4747import Language.PureScript.Types
4848import Language.PureScript.Names
@@ -62,13 +62,11 @@ data SimpleErrorMessage
6262 | MissingFFIModule ModuleName
6363 | MultipleFFIModules ModuleName [FilePath]
6464 | UnnecessaryFFIModule ModuleName FilePath
65− | InvalidExternsFile FilePath
6665 | CannotGetFileInfo FilePath
6766 | CannotReadFile FilePath
6867 | CannotWriteFile FilePath
6968 | InfiniteType Type
7069 | InfiniteKind Kind
71− | CannotReorderOperators
7270 | MultipleFixities Ident
7371 | OrphanTypeDeclaration Ident
7472 | OrphanFixityDeclaration String
@@ -108,11 +106,9 @@ data SimpleErrorMessage
108106 | CycleInTypeSynonym (Maybe ProperName)
109107 | CycleInModules [ModuleName]
110108 | NameIsUndefined Ident
111− | NameNotInScope Ident
112109 | UndefinedTypeVariable ProperName
113110 | PartiallyAppliedSynonym (Qualified ProperName)
114111 | EscapedSkolem (Maybe Expr)
115− | UnspecifiedSkolemScope
116112 | TypesDoNotUnify Type Type
117113 | KindsDoNotUnify Kind Kind
118114 | ConstrainedTypeUnified Type Type
@@ -126,16 +122,15 @@ data SimpleErrorMessage
126122 | ArgListLengthsDiffer Ident
127123 | OverlappingArgNames (Maybe Ident)
128124 | MissingClassMember Ident
129− | ExtraneousClassMember Ident
125+ | ExtraneousClassMember Ident (Qualified ProperName)
130126 | ExpectedType Type Kind
131127 | IncorrectConstructorArity (Qualified ProperName)
132− | SubsumptionCheckFailed
133128 | ExprDoesNotHaveType Expr Type
134129 | PropertyIsMissing String Type
135130 | CannotApplyFunction Type Expr
136131 | TypeSynonymInstance
137132 | OrphanInstance Ident (Qualified ProperName) [Type]
138− | InvalidNewtype
133+ | InvalidNewtype ProperName
139134 | InvalidInstanceHead Type
140135 | TransitiveExportError DeclarationRef [DeclarationRef]
141136 | ShadowedName Ident
@@ -202,13 +197,11 @@ errorCode em = case unwrapErrorMessage em of
202197 MissingFFIModule{} -> "MissingFFIModule"
203198 MultipleFFIModules{} -> "MultipleFFIModules"
204199 UnnecessaryFFIModule{} -> "UnnecessaryFFIModule"
205− InvalidExternsFile{} -> "InvalidExternsFile"
206200 CannotGetFileInfo{} -> "CannotGetFileInfo"
207201 CannotReadFile{} -> "CannotReadFile"
208202 CannotWriteFile{} -> "CannotWriteFile"
209203 InfiniteType{} -> "InfiniteType"
210204 InfiniteKind{} -> "InfiniteKind"
211− CannotReorderOperators -> "CannotReorderOperators"
212205 MultipleFixities{} -> "MultipleFixities"
213206 OrphanTypeDeclaration{} -> "OrphanTypeDeclaration"
214207 OrphanFixityDeclaration{} -> "OrphanFixityDeclaration"
@@ -248,11 +241,9 @@ errorCode em = case unwrapErrorMessage em of
248241 CycleInTypeSynonym{} -> "CycleInTypeSynonym"
249242 CycleInModules{} -> "CycleInModules"
250243 NameIsUndefined{} -> "NameIsUndefined"
251− NameNotInScope{} -> "NameNotInScope"
252244 UndefinedTypeVariable{} -> "UndefinedTypeVariable"
253245 PartiallyAppliedSynonym{} -> "PartiallyAppliedSynonym"
254246 EscapedSkolem{} -> "EscapedSkolem"
255− UnspecifiedSkolemScope -> "UnspecifiedSkolemScope"
256247 TypesDoNotUnify{} -> "TypesDoNotUnify"
257248 KindsDoNotUnify{} -> "KindsDoNotUnify"
258249 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
@@ -269,13 +260,12 @@ errorCode em = case unwrapErrorMessage em of
269260 ExtraneousClassMember{} -> "ExtraneousClassMember"
270261 ExpectedType{} -> "ExpectedType"
271262 IncorrectConstructorArity{} -> "IncorrectConstructorArity"
272− SubsumptionCheckFailed -> "SubsumptionCheckFailed"
273263 ExprDoesNotHaveType{} -> "ExprDoesNotHaveType"
274264 PropertyIsMissing{} -> "PropertyIsMissing"
275265 CannotApplyFunction{} -> "CannotApplyFunction"
276266 TypeSynonymInstance -> "TypeSynonymInstance"
277267 OrphanInstance{} -> "OrphanInstance"
278− InvalidNewtype -> "InvalidNewtype"
268+ InvalidNewtype{} -> "InvalidNewtype"
279269 InvalidInstanceHead{} -> "InvalidInstanceHead"
280270 TransitiveExportError{} -> "TransitiveExportError"
281271 ShadowedName{} -> "ShadowedName"
@@ -385,9 +375,9 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
385375 prettyPrintErrorMessage (ErrorMessage hints simple) =
386376 paras $
387377 map renderHint hints ++
388− renderSimpleErrorMessage simple :
389− suggestions simple ++
390− [line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."]
378+ [ renderSimpleErrorMessage simple
379+ , line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."
380+ ]
391381 where
392382 wikiUri :: String
393383 wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
@@ -410,7 +400,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
410400 , prettyPrintParseError err
411401 ]
412402 renderSimpleErrorMessage (ErrorParsingFFIModule path) =
413− paras [ line "Unable to parse module from FFI file: "
403+ paras [ line "Unable to parse foreign module:"
414404 , indent . line $ path
415405 ]
416406 renderSimpleErrorMessage (ErrorParsingModule err) =
@@ -418,29 +408,22 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
418408 , prettyPrintParseError err
419409 ]
420410 renderSimpleErrorMessage (MissingFFIModule mn) =
421− line $ "Missing FFI implementations for module " ++ runModuleName mn
411+ line $ "The foreign module implementation for module " ++ runModuleName mn ++ " is missing."
422412 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 ++ ": "
424414 , indent . line $ path
415+ , line $ "Module " ++ runModuleName mn ++ " does not contain any foreign import declarations, so a foreign module is not necessary."
425416 ]
426417 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 ++ ": "
428419 , indent . paras $ map line paths
429420 ]
430− renderSimpleErrorMessage (InvalidExternsFile path) =
431− paras [ line "Externs file is invalid: "
432− , indent . line $ path
433− ]
434421 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."
436423 renderSimpleErrorMessage InvalidDoLet =
437− line "Let statement cannot be the last statement in a do block. The last statement must be an expression."
438− renderSimpleErrorMessage CannotReorderOperators =
439− line "Unable to reorder operators"
440− renderSimpleErrorMessage UnspecifiedSkolemScope =
441− line "Skolem variable scope is unspecified"
424+ line "The last statement in a 'do' block must be an expression, but this block ends with a let binding."
442425 renderSimpleErrorMessage OverlappingNamesInLet =
443− line "Overlapping names in let binding."
426+ line "The same name was used more than once in a let binding."
444427 renderSimpleErrorMessage (InfiniteType ty) =
445428 paras [ line "An infinite type was inferred for an expression: "
446429 , indent $ typeAsBox ty
@@ -450,17 +433,17 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
450433 , indent $ line $ prettyPrintKind ki
451434 ]
452435 renderSimpleErrorMessage (MultipleFixities name) =
453− line $ "Multiple fixity declarations for " ++ showIdent name
436+ line $ "There are multiple fixity/precedence declarations for " ++ showIdent name
454437 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."
456439 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."
458441 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:")
460443 , indent . paras $ map (line . displaySourceSpan) filenames
461444 ]
462445 renderSimpleErrorMessage (RedefinedIdent name) =
463− line $ "Name " ++ showIdent name ++ " has been defined multiple times"
446+ line $ "The value " ++ showIdent name ++ " has been defined multiple times"
464447 renderSimpleErrorMessage (UnknownModule mn) =
465448 line $ "Unknown module " ++ runModuleName mn
466449 renderSimpleErrorMessage (UnknownType name) =
@@ -474,25 +457,36 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
474457 renderSimpleErrorMessage (UnknownDataConstructor dc tc) =
475458 line $ "Unknown data constructor " ++ showQualified runProperName dc ++ foldMap ((" for type constructor " ++) . showQualified runProperName) tc
476459 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."
462+ ]
478463 renderSimpleErrorMessage (UnknownExportType name) =
479464 line $ "Cannot export unknown type " ++ runProperName name
480465 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."
468+ ]
482469 renderSimpleErrorMessage (UnknownExportTypeClass name) =
483470 line $ "Cannot export unknown type class " ++ runProperName name
484471 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."
474+ ]
486475 renderSimpleErrorMessage (UnknownExportValue name) =
487476 line $ "Cannot export unknown value " ++ showIdent name
488477 renderSimpleErrorMessage (UnknownExportModule name) =
489− line $ "Cannot export unknown module " ++ runModuleName name ++ ", it either does not exist or has not been imported by the current module"
478+ paras [ line $ "Cannot export unknown module " ++ runModuleName name
479+ , line "It either does not exist or has not been imported by the current module."
480+ ]
490481 renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
491482 line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon
492483 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."
494485 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 ++ ")"
489+ ]
496490 renderSimpleErrorMessage (ConflictingImports nm m1 m2) =
497491 line $ "Conflicting imports for " ++ nm ++ " from modules " ++ runModuleName m1 ++ " and " ++ runModuleName m2
498492 renderSimpleErrorMessage (ConflictingTypeDecls nm) =
@@ -500,13 +494,13 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
500494 renderSimpleErrorMessage (ConflictingCtorDecls nm) =
501495 line $ "Conflicting data constructor declarations for " ++ runProperName nm
502496 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."
504498 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."
506500 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."
508502 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."
510504 renderSimpleErrorMessage (DuplicateModuleName mn) =
511505 line $ "Module " ++ runModuleName mn ++ " has been defined multiple times."
512506 renderSimpleErrorMessage (DuplicateClassExport nm) =
@@ -514,19 +508,24 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
514508 renderSimpleErrorMessage (DuplicateValueExport nm) =
515509 line $ "Duplicate export declaration for value " ++ showIdent nm
516510 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."
518512 renderSimpleErrorMessage (CycleInModules mns) =
519− line $ "Cycle in module dependencies: " ++ intercalate ", " (map runModuleName mns)
520− renderSimpleErrorMessage (CycleInTypeSynonym pn) =
521− line $ "Cycle in type synonym" ++ foldMap ((" " ++) . runProperName) pn
513+ paras [ line $ "There is a cycle in module dependencies in these modules: "
514+ , indent $ paras (map (line . runModuleName) mns)
515+ ]
516+ renderSimpleErrorMessage (CycleInTypeSynonym name) =
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+ ]
522523 renderSimpleErrorMessage (NameIsUndefined ident) =
523− line $ showIdent ident ++ " is undefined"
524− renderSimpleErrorMessage (NameNotInScope ident) =
525− line $ showIdent ident ++ " may not be defined in the current scope"
524+ line $ "Value " ++ showIdent ident ++ " is undefined."
526525 renderSimpleErrorMessage (UndefinedTypeVariable name) =
527− line $ "Type variable " ++ runProperName name ++ " is undefined"
526+ line $ "Type variable " ++ runProperName name ++ " is undefined."
528527 renderSimpleErrorMessage (PartiallyAppliedSynonym name) =
529− paras [ line $ "Partially applied type synonym " ++ showQualified runProperName name
528+ paras [ line $ "Type synonym " ++ showQualified runProperName name ++ " is partially applied."
530529 , line "Type synonyms must be applied to all of their type arguments."
531530 ]
532531 renderSimpleErrorMessage (EscapedSkolem binding) =
@@ -535,70 +534,72 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
535534 , indent $ prettyPrintValue expr
536535 ]) binding
537536 renderSimpleErrorMessage (TypesDoNotUnify t1 t2)
538− = paras [ line "Cannot unify type"
537+ = paras [ line "Could not match expected type"
539538 , indent $ typeAsBox t1
540− , line "with type"
539+ , line "with actual type"
541540 , indent $ typeAsBox t2
542541 ]
543542 renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
544− paras [ line "Cannot unify kind"
543+ paras [ line "Could not match expected kind"
545544 , indent $ line $ prettyPrintKind k1
546− , line "with kind"
545+ , line "with actual kind"
547546 , indent $ line $ prettyPrintKind k2
548547 ]
549548 renderSimpleErrorMessage (ConstrainedTypeUnified t1 t2) =
550− paras [ line "Cannot unify constrained type"
549+ paras [ line "Could not match constrained type"
551550 , indent $ typeAsBox t1
552551 , line "with type"
553552 , indent $ typeAsBox t2
554553 ]
555554 renderSimpleErrorMessage (OverlappingInstances nm ts (d : ds)) =
556− paras [ line "Overlapping instances found for"
555+ paras [ line "Overlapping type class instances found for"
557556 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
558557 , Box.vcat Box.left (map typeAtomAsBox ts)
559558 ]
560559 , line "The following instances were found:"
561560 , 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."
562563 ]
563− renderSimpleErrorMessage OverlappingInstances{} = error "OverlappingInstances: empty instance list"
564+ renderSimpleErrorMessage OverlappingInstances{} = internalError "OverlappingInstances: empty instance list"
564565 renderSimpleErrorMessage (NoInstanceFound nm ts) =
565− paras [ line "No instance found for"
566+ paras [ line "No type class instance was found for"
566567 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
567568 , Box.vcat Box.left (map typeAtomAsBox ts)
568569 ]
569570 ]
570571 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
571− paras [ line "Instance for"
572+ paras [ line "Type class instance for"
572573 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
573574 , Box.vcat Box.left (map typeAtomAsBox ts)
574575 ]
575576 , line "is possibly infinite."
576577 ]
577578 renderSimpleErrorMessage (CannotDerive nm ts) =
578− paras [ line "Cannot derive an instance for"
579+ paras [ line "Cannot derive a type class instance for"
579580 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
580581 , Box.vcat Box.left (map typeAtomAsBox ts)
581582 ]
582583 ]
583584 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."
585586 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." ]
587588 <> foldMap (\expr' -> [ line "Relevant expression: "
588589 , indent $ prettyPrintValue expr'
589590 ]) expr
590591 renderSimpleErrorMessage (DuplicateTypeArgument name) =
591− line $ "Duplicate type argument " ++ show name
592+ line $ "Type argument " ++ show name ++ " appears more than once."
592593 renderSimpleErrorMessage (DuplicateValueDeclaration nm) =
593− line $ "Duplicate value declaration for " ++ showIdent nm
594+ line $ "Multiple value declarations exist for " ++ showIdent nm ++ "."
594595 renderSimpleErrorMessage (ArgListLengthsDiffer ident) =
595596 line $ "Argument list lengths differ in declaration " ++ showIdent ident
596597 renderSimpleErrorMessage (OverlappingArgNames ident) =
597598 line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . showIdent) ident
598599 renderSimpleErrorMessage (MissingClassMember ident) =
599− line $ "Member " ++ showIdent ident ++ " has not been implemented"
600− renderSimpleErrorMessage (ExtraneousClassMember ident) =
601− line $ "Member " ++ showIdent ident ++ " is not a member of the class being instantiated"
600+ line $ "Type class member " ++ showIdent ident ++ " has not been implemented."
601+ renderSimpleErrorMessage (ExtraneousClassMember ident className) =
602+ line $ showIdent ident ++ " is not a member of type class " ++ showQualified runProperName className
602603 renderSimpleErrorMessage (ExpectedType ty kind) =
603604 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
604605 , line "The error arises from the type"
@@ -608,8 +609,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
608609 , line "instead."
609610 ]
610611 renderSimpleErrorMessage (IncorrectConstructorArity nm) =
611− line $ "Wrong number of arguments to constructor " ++ showQualified runProperName nm
612− renderSimpleErrorMessage SubsumptionCheckFailed = line "Unable to check type subsumption"
612+ line $ "Data constructor " ++ showQualified runProperName nm ++ " was given the wrong number of arguments in a case expression."
613613 renderSimpleErrorMessage (ExprDoesNotHaveType expr ty) =
614614 paras [ line "Expression"
615615 , indent $ prettyPrintValue expr
@@ -617,20 +617,20 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
617617 , indent $ typeAsBox ty
618618 ]
619619 renderSimpleErrorMessage (PropertyIsMissing prop row) =
620− paras [ line "Row"
620+ paras [ line "Row type"
621621 , indent $ prettyPrintRowWith '(' ')' row
622− , line $ "lacks required property " ++ show prop
622+ , line $ "lacks required label " ++ show prop
623623 ]
624624 renderSimpleErrorMessage (CannotApplyFunction fn arg) =
625− paras [ line "Cannot apply function of type"
625+ paras [ line "A function of type"
626626 , indent $ typeAsBox fn
627− , line "to argument"
627+ , line "can not be applied to the argument"
628628 , indent $ prettyPrintValue arg
629629 ]
630630 renderSimpleErrorMessage TypeSynonymInstance =
631− line "Type synonym instances are disallowed"
631+ line "Type class instances for type synonyms are disallowed."
632632 renderSimpleErrorMessage (OrphanInstance nm cnm ts) =
633− paras [ line $ "Instance " ++ showIdent nm ++ " for "
633+ paras [ line $ "Type class instance " ++ showIdent nm ++ " for "
634634 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName cnm)
635635 , Box.vcat Box.left (map typeAtomAsBox ts)
636636 ]
@@ -638,32 +638,37 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
638638 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
639639 , line "Consider moving the instance, if possible, or using a newtype wrapper."
640640 ]
641− renderSimpleErrorMessage InvalidNewtype =
642− line "Newtypes must define a single constructor with a single argument"
641+ renderSimpleErrorMessage (InvalidNewtype name) =
642+ paras [ line $ "Newtype " ++ runProperName name ++ " is invalid."
643+ , line "Newtypes must define a single constructor with a single argument."
644+ ]
643645 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"
645647 , 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."
646649 ]
647650 renderSimpleErrorMessage (TransitiveExportError x ys) =
648651 paras $ line ("An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
649652 : map (line . prettyPrintExport) ys
650653 renderSimpleErrorMessage (ShadowedName nm) =
651− line $ "Name '" ++ showIdent nm ++ "' was shadowed"
654+ line $ "Name '" ++ showIdent nm ++ "' was shadowed."
652655 renderSimpleErrorMessage (ShadowedTypeVar tv) =
653− line $ "Type variable '" ++ tv ++ "' was shadowed"
656+ line $ "Type variable '" ++ tv ++ "' was shadowed."
654657 renderSimpleErrorMessage (UnusedTypeVar tv) =
655− line $ "Type variable '" ++ tv ++ "' was declared but not used"
658+ line $ "Type variable '" ++ tv ++ "' was declared but not used."
656659 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 ++ "."
658661 , line "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
659662 , indent . line $ showIdent opName ++ " = someMember"
660663 ]
661664 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."
663666 renderSimpleErrorMessage (ImportHidingModule name) =
664− line $ "Attempted to hide module " ++ runModuleName name ++ " in import expression, this is not permitted"
667+ paras [ line $ "'hiding' imports cannot be used to hide modules."
668+ , line $ "An attempt was made to hide the import of " ++ runModuleName name
669+ ]
665670 renderSimpleErrorMessage (WildcardInferredType ty) =
666− paras [ line "The wildcard type definition has the inferred type "
671+ paras [ line "Wildcard type definition has the inferred type "
667672 , indent $ typeAsBox ty
668673 ]
669674 renderSimpleErrorMessage (MissingTypeDeclaration ident ty) =
@@ -692,7 +697,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
692697 renderHint (NotYetDefined names) =
693698 line $ "The following are not yet defined here: " ++ intercalate ", " (map showIdent names) ++ ":"
694699 renderHint (ErrorUnifyingTypes t1 t2) =
695− paras [ lineWithLevel "unifying type "
700+ paras [ lineWithLevel "while trying to match type "
696701 , indent $ typeAsBox t1
697702 , line "with type"
698703 , indent $ typeAsBox t2
@@ -705,9 +710,9 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
705710 paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
706711 ]
707712 renderHint (ErrorInSubsumption t1 t2) =
708− paras [ lineWithLevel "checking that type "
713+ paras [ lineWithLevel "checking that type"
709714 , indent $ typeAsBox t1
710− , line "subsumes type"
715+ , line "is at least as general as type"
711716 , indent $ typeAsBox t2
712717 ]
713718 renderHint (ErrorInInstance nm ts) =
@@ -717,21 +722,21 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
717722 ]
718723 ]
719724 renderHint (ErrorCheckingKind ty) =
720− paras [ lineWithLevel "checking kind of type "
725+ paras [ lineWithLevel "checking kind of type"
721726 , indent $ typeAsBox ty
722727 ]
723728 renderHint (ErrorInferringType expr) =
724− paras [ lineWithLevel "inferring type of value "
729+ paras [ lineWithLevel "inferring type of expression"
725730 , indent $ prettyPrintValue expr
726731 ]
727732 renderHint (ErrorCheckingType expr ty) =
728− paras [ lineWithLevel "checking that value "
733+ paras [ lineWithLevel "checking that expression"
729734 , indent $ prettyPrintValue expr
730735 , line "has type"
731736 , indent $ typeAsBox ty
732737 ]
733738 renderHint (ErrorInApplication f t a) =
734− paras [ lineWithLevel "applying function"
739+ paras [ lineWithLevel "applying a function"
735740 , indent $ prettyPrintValue f
736741 , line "of type"
737742 , indent $ typeAsBox t
@@ -765,15 +770,6 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
765770 Error -> "error"
766771 Warning -> "warning"
767772
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 ++ ")"
771− ]
772− suggestions (TypesDoNotUnify t1 t2)
773− | isObject t1 && isFunction t2 = [line "Note that function composition in PureScript is defined using (<<<)"]
774− | otherwise = []
775− suggestions _ = []
776−
777773 paras :: [Box.Box] -> Box.Box
778774 paras = Box.vcat Box.left
779775