@@ -42,7 +42,6 @@ import Control.Monad.Trans.State.Lazy
4242import Control.Arrow(first)
4343
4444import Language.PureScript.AST
45−import Language.PureScript.Environment (isObject, isFunction)
4645import Language.PureScript.Pretty
4746import Language.PureScript.Types
4847import Language.PureScript.Names
@@ -62,13 +61,11 @@ data SimpleErrorMessage
6261 | MissingFFIModule ModuleName
6362 | MultipleFFIModules ModuleName [FilePath]
6463 | UnnecessaryFFIModule ModuleName FilePath
65− | InvalidExternsFile FilePath
6664 | CannotGetFileInfo FilePath
6765 | CannotReadFile FilePath
6866 | CannotWriteFile FilePath
6967 | InfiniteType Type
7068 | InfiniteKind Kind
71− | CannotReorderOperators
7269 | MultipleFixities Ident
7370 | OrphanTypeDeclaration Ident
7471 | OrphanFixityDeclaration String
@@ -112,7 +109,6 @@ data SimpleErrorMessage
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,10 +122,9 @@ 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
@@ -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"
@@ -252,7 +245,6 @@ errorCode em = case unwrapErrorMessage em of
252245 UndefinedTypeVariable{} -> "UndefinedTypeVariable"
253246 PartiallyAppliedSynonym{} -> "PartiallyAppliedSynonym"
254247 EscapedSkolem{} -> "EscapedSkolem"
255− UnspecifiedSkolemScope -> "UnspecifiedSkolemScope"
256248 TypesDoNotUnify{} -> "TypesDoNotUnify"
257249 KindsDoNotUnify{} -> "KindsDoNotUnify"
258250 ConstrainedTypeUnified{} -> "ConstrainedTypeUnified"
@@ -269,7 +261,6 @@ errorCode em = case unwrapErrorMessage em of
269261 ExtraneousClassMember{} -> "ExtraneousClassMember"
270262 ExpectedType{} -> "ExpectedType"
271263 IncorrectConstructorArity{} -> "IncorrectConstructorArity"
272− SubsumptionCheckFailed -> "SubsumptionCheckFailed"
273264 ExprDoesNotHaveType{} -> "ExprDoesNotHaveType"
274265 PropertyIsMissing{} -> "PropertyIsMissing"
275266 CannotApplyFunction{} -> "CannotApplyFunction"
@@ -385,9 +376,9 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
385376 prettyPrintErrorMessage (ErrorMessage hints simple) =
386377 paras $
387378 map renderHint hints ++
388− renderSimpleErrorMessage simple :
389− suggestions simple ++
390− [line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."]
379+ [ renderSimpleErrorMessage simple
380+ , line $ "See " ++ wikiUri ++ " for more information, or to contribute content related to this " ++ levelText ++ "."
381+ ]
391382 where
392383 wikiUri :: String
393384 wikiUri = "https://github.com/purescript/purescript/wiki/Error-Code-" ++ errorCode e
@@ -410,37 +401,37 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
410401 , prettyPrintParseError err
411402 ]
412403 renderSimpleErrorMessage (ErrorParsingFFIModule path) =
413− paras [ line "Unable to parse module from FFI file: "
404+ paras [ line "Unable to parse foreign module:"
414405 , indent . line $ path
406+ , line "Ensure that all foreign modules contain a single module header at the start of a line, as follows:"
407+ , indent $ line "// module A.B.C"
415408 ]
416409 renderSimpleErrorMessage (ErrorParsingModule err) =
417410 paras [ line "Unable to parse module: "
418411 , prettyPrintParseError err
419412 ]
420413 renderSimpleErrorMessage (MissingFFIModule mn) =
421− line $ "Missing FFI implementations for module " ++ runModuleName mn
414+ paras [ line $ "Missing foreign module implementation for module " ++ runModuleName mn
415+ , line $ "Provide your foreign module implementation using the --ffi command line option, and ensure that your module contains the following module header:"
416+ , indent . line $ "// module " ++ runModuleName mn
417+ ]
422418 renderSimpleErrorMessage (UnnecessaryFFIModule mn path) =
423− paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ runModuleName mn ++ ": "
419+ paras [ line $ "An unnecessary foreign module implementation was provided for module " ++ runModuleName mn ++ ": "
424420 , indent . line $ path
421+ , line $ "Module " ++ runModuleName mn ++ " does not contain any foreign import declarations, so a foreign module is not necessary."
425422 ]
426423 renderSimpleErrorMessage (MultipleFFIModules mn paths) =
427− paras [ line $ "Multiple FFI implementations have been provided for module " ++ runModuleName mn ++ ": "
424+ paras [ line $ "Multiple foreign module implementations have been provided for module " ++ runModuleName mn ++ ": "
428425 , indent . paras $ map line paths
429− ]
430− renderSimpleErrorMessage (InvalidExternsFile path) =
431− paras [ line "Externs file is invalid: "
432− , indent . line $ path
426+ , line "Foreign modules are identified by a unique module name, as follows:"
427+ , indent $ line "// module A.B.C"
433428 ]
434429 renderSimpleErrorMessage InvalidDoBind =
435− line "Bind statement cannot be the last statement in a do block. The last statement must be an expression."
430+ line "The last statement in a 'do' block must be an expression, but this block ends with a binder."
436431 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"
432+ line "The last statement in a 'do' block must be an expression, but this block ends with a let binding."
442433 renderSimpleErrorMessage OverlappingNamesInLet =
443− line "Overlapping names in let binding."
434+ line "The same name was used more than once in a let binding."
444435 renderSimpleErrorMessage (InfiniteType ty) =
445436 paras [ line "An infinite type was inferred for an expression: "
446437 , indent $ typeAsBox ty
@@ -450,17 +441,17 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
450441 , indent $ line $ prettyPrintKind ki
451442 ]
452443 renderSimpleErrorMessage (MultipleFixities name) =
453− line $ "Multiple fixity declarations for " ++ showIdent name
444+ line $ "There are multiple fixity/precedence declarations for " ++ showIdent name
454445 renderSimpleErrorMessage (OrphanTypeDeclaration nm) =
455− line $ "Orphan type declaration for " ++ showIdent nm
446+ line $ "The type declaration for " ++ showIdent nm ++ " should be followed by its definition."
456447 renderSimpleErrorMessage (OrphanFixityDeclaration op) =
457− line $ "Orphan fixity declaration for " ++ show op
448+ line $ "The fixity/precedence declaration for " ++ show op ++ " should appear in the same module as its definition."
458449 renderSimpleErrorMessage (RedefinedModule name filenames) =
459− paras [ line ("Module " ++ runModuleName name ++ " has been defined multiple times:")
450+ paras [ line ("The module " ++ runModuleName name ++ " has been defined multiple times:")
460451 , indent . paras $ map (line . displaySourceSpan) filenames
461452 ]
462453 renderSimpleErrorMessage (RedefinedIdent name) =
463− line $ "Name " ++ showIdent name ++ " has been defined multiple times"
454+ line $ "The name " ++ showIdent name ++ " has been defined multiple times"
464455 renderSimpleErrorMessage (UnknownModule mn) =
465456 line $ "Unknown module " ++ runModuleName mn
466457 renderSimpleErrorMessage (UnknownType name) =
@@ -474,25 +465,30 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
474465 renderSimpleErrorMessage (UnknownDataConstructor dc tc) =
475466 line $ "Unknown data constructor " ++ showQualified runProperName dc ++ foldMap ((" for type constructor " ++) . showQualified runProperName) tc
476467 renderSimpleErrorMessage (UnknownImportType mn name) =
477− line $ "Module " ++ runModuleName mn ++ " does not export type " ++ runProperName name
468+ line $ "The type " ++ runProperName name ++ " is not exported by the module " ++ runModuleName mn
478469 renderSimpleErrorMessage (UnknownExportType name) =
479470 line $ "Cannot export unknown type " ++ runProperName name
480471 renderSimpleErrorMessage (UnknownImportTypeClass mn name) =
481− line $ "Module " ++ runModuleName mn ++ " does not export type class " ++ runProperName name
472+ line $ "The type class " ++ runProperName name ++ " is not exported by the module " ++ runModuleName mn
482473 renderSimpleErrorMessage (UnknownExportTypeClass name) =
483474 line $ "Cannot export unknown type class " ++ runProperName name
484475 renderSimpleErrorMessage (UnknownImportValue mn name) =
485− line $ "Module " ++ runModuleName mn ++ " does not export value " ++ showIdent name
476+ line $ "The value " ++ showIdent name ++ " is not exported by the module " ++ runModuleName mn
486477 renderSimpleErrorMessage (UnknownExportValue name) =
487478 line $ "Cannot export unknown value " ++ showIdent name
488479 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"
480+ paras [ line $ "Cannot export unknown module " ++ runModuleName name
481+ , line "It either does not exist or has not been imported by the current module."
482+ ]
490483 renderSimpleErrorMessage (UnknownImportDataConstructor mn tcon dcon) =
491− line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon
484+ line $ "The data constructor " ++ runProperName dcon ++ " (for type " ++ runProperName tcon ++ ") is not exported by the module " ++ runModuleName mn
492485 renderSimpleErrorMessage (UnknownExportDataConstructor tcon dcon) =
493− line $ "Cannot export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon ++ " as it has not been declared"
486+ line $ "Cannot export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon ++ ", as it has not been declared."
494487 renderSimpleErrorMessage (ConflictingImport nm mn) =
495− line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ runModuleName mn
488+ paras [ line $ "Cannot declare " ++ show nm ++ ", since another declaration of that name was imported from the module " ++ runModuleName mn
489+ , line $ "Consider hiding " ++ show nm ++ " when importing " ++ runModuleName mn ++ ":"
490+ , indent . line $ "import " ++ runModuleName mn ++ " hiding (" ++ nm ++ ")"
491+ ]
496492 renderSimpleErrorMessage (ConflictingImports nm m1 m2) =
497493 line $ "Conflicting imports for " ++ nm ++ " from modules " ++ runModuleName m1 ++ " and " ++ runModuleName m2
498494 renderSimpleErrorMessage (ConflictingTypeDecls nm) =
@@ -500,33 +496,41 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
500496 renderSimpleErrorMessage (ConflictingCtorDecls nm) =
501497 line $ "Conflicting data constructor declarations for " ++ runProperName nm
502498 renderSimpleErrorMessage (TypeConflictsWithClass nm) =
503− line $ "Type " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
499+ line $ "The type " ++ runProperName nm ++ " conflicts with type class declaration of the same name."
504500 renderSimpleErrorMessage (CtorConflictsWithClass nm) =
505− line $ "Data constructor " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
501+ line $ "The data constructor " ++ runProperName nm ++ " conflicts with type class declaration of the same name."
506502 renderSimpleErrorMessage (ClassConflictsWithType nm) =
507− line $ "Type class " ++ runProperName nm ++ " conflicts with type declaration of the same name"
503+ line $ "The type class " ++ runProperName nm ++ " conflicts with type declaration of the same name."
508504 renderSimpleErrorMessage (ClassConflictsWithCtor nm) =
509− line $ "Type class " ++ runProperName nm ++ " conflicts with data constructor declaration of the same name"
505+ line $ "The type class " ++ runProperName nm ++ " conflicts with data constructor declaration of the same name."
510506 renderSimpleErrorMessage (DuplicateModuleName mn) =
511− line $ "Module " ++ runModuleName mn ++ " has been defined multiple times."
507+ line $ "The module " ++ runModuleName mn ++ " has been defined multiple times."
512508 renderSimpleErrorMessage (DuplicateClassExport nm) =
513509 line $ "Duplicate export declaration for type class " ++ runProperName nm
514510 renderSimpleErrorMessage (DuplicateValueExport nm) =
515511 line $ "Duplicate export declaration for value " ++ showIdent nm
516512 renderSimpleErrorMessage (CycleInDeclaration nm) =
517− line $ "Cycle in declaration of " ++ showIdent nm
513+ paras [ line $ "The declaration of " ++ showIdent nm ++ " contains a cycle."
514+ , line $ "The value of " ++ showIdent nm ++ " may not be defined here, so this reference is not allowed."
515+ , line "You might be able to evaluate this expression lazily, using something like Control.Lazy.fix"
516+ ]
518517 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
518+ line $ "There is a cycle in the module dependencies: " ++ intercalate ", " (map runModuleName mns)
519+ renderSimpleErrorMessage (CycleInTypeSynonym name) =
520+ paras [ line $ case name of
521+ Just pn -> "A cycle appears in the definition of the type synonym " ++ runProperName pn
522+ Nothing -> "A cycle appears in a set of type synonym definitions."
523+ , line "Cycles are disallowed because they can lead to loops in the type checker."
524+ , line "Consider using a 'newtype' instead."
525+ ]
522526 renderSimpleErrorMessage (NameIsUndefined ident) =
523− line $ showIdent ident ++ " is undefined"
527+ line $ "The name " ++ showIdent ident ++ " is undefined."
524528 renderSimpleErrorMessage (NameNotInScope ident) =
525− line $ showIdent ident ++ " may not be defined in the current scope"
529+ line $ "The name " ++ showIdent ident ++ " may not be defined in the current scope."
526530 renderSimpleErrorMessage (UndefinedTypeVariable name) =
527− line $ "Type variable " ++ runProperName name ++ " is undefined"
531+ line $ "The type variable " ++ runProperName name ++ " is undefined."
528532 renderSimpleErrorMessage (PartiallyAppliedSynonym name) =
529− paras [ line $ "Partially applied type synonym " ++ showQualified runProperName name
533+ paras [ line $ "The type synonym " ++ showQualified runProperName name ++ " is partially applied."
530534 , line "Type synonyms must be applied to all of their type arguments."
531535 ]
532536 renderSimpleErrorMessage (EscapedSkolem binding) =
@@ -535,25 +539,25 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
535539 , indent $ prettyPrintValue expr
536540 ]) binding
537541 renderSimpleErrorMessage (TypesDoNotUnify t1 t2)
538− = paras [ line "Cannot unify type"
542+ = paras [ line "The type"
539543 , indent $ typeAsBox t1
540− , line "with type"
544+ , line "cannot be made equal to the type"
541545 , indent $ typeAsBox t2
542546 ]
543547 renderSimpleErrorMessage (KindsDoNotUnify k1 k2) =
544− paras [ line "Cannot unify kind"
548+ paras [ line "The kind"
545549 , indent $ line $ prettyPrintKind k1
546− , line "with kind"
550+ , line "cannot be made equal to the kind"
547551 , indent $ line $ prettyPrintKind k2
548552 ]
549553 renderSimpleErrorMessage (ConstrainedTypeUnified t1 t2) =
550− paras [ line "Cannot unify constrained type"
554+ paras [ line "The constrained type"
551555 , indent $ typeAsBox t1
552− , line "with type"
556+ , line "cannot be made equal to the kind"
553557 , indent $ typeAsBox t2
554558 ]
555559 renderSimpleErrorMessage (OverlappingInstances nm ts (d : ds)) =
556− paras [ line "Overlapping instances found for"
560+ paras [ line "Overlapping type class instances found for"
557561 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
558562 , Box.vcat Box.left (map typeAtomAsBox ts)
559563 ]
@@ -562,43 +566,43 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
562566 ]
563567 renderSimpleErrorMessage OverlappingInstances{} = error "OverlappingInstances: empty instance list"
564568 renderSimpleErrorMessage (NoInstanceFound nm ts) =
565− paras [ line "No instance found for"
569+ paras [ line "No type class instance was found for"
566570 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
567571 , Box.vcat Box.left (map typeAtomAsBox ts)
568572 ]
569573 ]
570574 renderSimpleErrorMessage (PossiblyInfiniteInstance nm ts) =
571− paras [ line "Instance for"
575+ paras [ line "The type class instance for"
572576 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
573577 , Box.vcat Box.left (map typeAtomAsBox ts)
574578 ]
575579 , line "is possibly infinite."
576580 ]
577581 renderSimpleErrorMessage (CannotDerive nm ts) =
578− paras [ line "Cannot derive an instance for"
582+ paras [ line "Cannot derive a type class instance for"
579583 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName nm)
580584 , Box.vcat Box.left (map typeAtomAsBox ts)
581585 ]
582586 ]
583587 renderSimpleErrorMessage (CannotFindDerivingType nm) =
584− line $ "Cannot derive instance, because the type declaration for " ++ runProperName nm ++ " could not be found."
588+ line $ "Cannot derive a type class instance, because the type declaration for " ++ runProperName nm ++ " could not be found."
585589 renderSimpleErrorMessage (DuplicateLabel l expr) =
586− paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
590+ paras $ [ line $ "The duplicate label " ++ show l ++ " appears in a row type." ]
587591 <> foldMap (\expr' -> [ line "Relevant expression: "
588592 , indent $ prettyPrintValue expr'
589593 ]) expr
590594 renderSimpleErrorMessage (DuplicateTypeArgument name) =
591− line $ "Duplicate type argument " ++ show name
595+ line $ "The type argument " ++ show name ++ " appears more than once."
592596 renderSimpleErrorMessage (DuplicateValueDeclaration nm) =
593− line $ "Duplicate value declaration for " ++ showIdent nm
597+ line $ "Multiple value declarations exist for " ++ showIdent nm ++ "."
594598 renderSimpleErrorMessage (ArgListLengthsDiffer ident) =
595599 line $ "Argument list lengths differ in declaration " ++ showIdent ident
596600 renderSimpleErrorMessage (OverlappingArgNames ident) =
597601 line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . showIdent) ident
598602 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"
603+ line $ "The type class member " ++ showIdent ident ++ " has not been implemented."
604+ renderSimpleErrorMessage (ExtraneousClassMember ident className) =
605+ line $ showIdent ident ++ " is not a member of type class " ++ showQualified runProperName className
602606 renderSimpleErrorMessage (ExpectedType ty kind) =
603607 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
604608 , line "The error arises from the type"
@@ -608,29 +612,28 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
608612 , line "instead."
609613 ]
610614 renderSimpleErrorMessage (IncorrectConstructorArity nm) =
611− line $ "Wrong number of arguments to constructor " ++ showQualified runProperName nm
612− renderSimpleErrorMessage SubsumptionCheckFailed = line "Unable to check type subsumption"
615+ line $ "The data constructor " ++ showQualified runProperName nm ++ " was given the wrong number of arguments in a case expression."
613616 renderSimpleErrorMessage (ExprDoesNotHaveType expr ty) =
614− paras [ line "Expression"
617+ paras [ line "The expression"
615618 , indent $ prettyPrintValue expr
616619 , line "does not have type"
617620 , indent $ typeAsBox ty
618621 ]
619622 renderSimpleErrorMessage (PropertyIsMissing prop row) =
620− paras [ line "Row"
623+ paras [ line "The row type"
621624 , indent $ prettyPrintRowWith '(' ')' row
622− , line $ "lacks required property " ++ show prop
625+ , line $ "lacks the required property " ++ show prop
623626 ]
624627 renderSimpleErrorMessage (CannotApplyFunction fn arg) =
625− paras [ line "Cannot apply function of type"
628+ paras [ line "A function of type"
626629 , indent $ typeAsBox fn
627− , line "to argument"
630+ , line "can not be applied to the argument"
628631 , indent $ prettyPrintValue arg
629632 ]
630633 renderSimpleErrorMessage TypeSynonymInstance =
631− line "Type synonym instances are disallowed"
634+ line "Type class instances for type synonyms are disallowed."
632635 renderSimpleErrorMessage (OrphanInstance nm cnm ts) =
633− paras [ line $ "Instance " ++ showIdent nm ++ " for "
636+ paras [ line $ "The type class instance " ++ showIdent nm ++ " for "
634637 , indent $ Box.hsep 1 Box.left [ line (showQualified runProperName cnm)
635638 , Box.vcat Box.left (map typeAtomAsBox ts)
636639 ]
@@ -639,29 +642,31 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
639642 , line "Consider moving the instance, if possible, or using a newtype wrapper."
640643 ]
641644 renderSimpleErrorMessage InvalidNewtype =
642− line "Newtypes must define a single constructor with a single argument"
645+ line "Newtypes must define a single constructor with a single argument."
643646 renderSimpleErrorMessage (InvalidInstanceHead ty) =
644− paras [ line "Invalid type in class instance head:"
647+ paras [ line "An invalid type appears in a type class instance head:"
645648 , indent $ typeAsBox ty
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 $ "The name '" ++ showIdent nm ++ "' was shadowed."
652655 renderSimpleErrorMessage (ShadowedTypeVar tv) =
653− line $ "Type variable '" ++ tv ++ "' was shadowed"
656+ line $ "The type variable '" ++ tv ++ "' was shadowed."
654657 renderSimpleErrorMessage (UnusedTypeVar tv) =
655− line $ "Type variable '" ++ tv ++ "' was declared but not used"
658+ line $ "The 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 $ "The 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) =
666671 paras [ line "The wildcard type definition has the inferred type "
667672 , indent $ typeAsBox ty
@@ -692,9 +697,9 @@ 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 make the type "
696701 , indent $ typeAsBox t1
697− , line "with type"
702+ , line "equal to the type"
698703 , indent $ typeAsBox t2
699704 ]
700705 renderHint (ErrorInExpression expr) =
@@ -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 the type"
709714 , indent $ typeAsBox t1
710− , line "subsumes type"
715+ , line "is more general than the type"
711716 , indent $ typeAsBox t2
712717 ]
713718 renderHint (ErrorInInstance nm ts) =
@@ -717,25 +722,25 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage . positionHintsFir
717722 ]
718723 ]
719724 renderHint (ErrorCheckingKind ty) =
720− paras [ lineWithLevel "checking kind of type "
725+ paras [ lineWithLevel "checking the kind of the type"
721726 , indent $ typeAsBox ty
722727 ]
723728 renderHint (ErrorInferringType expr) =
724− paras [ lineWithLevel "inferring type of value "
729+ paras [ lineWithLevel "inferring the type of the expression"
725730 , indent $ prettyPrintValue expr
726731 ]
727732 renderHint (ErrorCheckingType expr ty) =
728− paras [ lineWithLevel "checking that value "
733+ paras [ lineWithLevel "checking that the expression"
729734 , indent $ prettyPrintValue expr
730− , line "has type"
735+ , line "has the 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
738− , line "to argument"
743+ , line "to the argument"
739744 , indent $ prettyPrintValue a
740745 ]
741746 renderHint (ErrorInDataConstructor nm) =
@@ -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