@@ -309,7 +309,7 @@ onErrorMessages :: (ErrorMessage -> ErrorMessage) -> MultipleErrors -> MultipleE
309309onErrorMessages f = MultipleErrors . map f . runMultipleErrors
310310
311311-- | The various types of things which might need to be relabelled in errors messages.
312−data LabelType = TypeLabel | SkolemLabel String deriving (Show, Eq, Ord)
312+data LabelType = TypeLabel | SkolemLabel String deriving (Show, Read, Eq, Ord)
313313
314314-- | A map from rigid type variable name/unknown variable pairs to new variables.
315315type UnknownMap = M.Map (LabelType, Unknown) Unknown
@@ -430,13 +430,13 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
430430 , indent . prettyPrintParseError $ err
431431 ]
432432 goSimple (MissingFFIModule mn) =
433− line $ "Missing FFI implementations for module " ++ show mn
433+ line $ "Missing FFI implementations for module " ++ runModuleName mn
434434 goSimple (UnnecessaryFFIModule mn path) =
435− paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ show mn ++ ": "
435+ paras [ line $ "Unnecessary FFI implementations have been provided for module " ++ runModuleName mn ++ ": "
436436 , indent . line $ path
437437 ]
438438 goSimple (MultipleFFIModules mn paths) =
439− paras $ [ line $ "Multiple FFI implementations have been provided for module " ++ show mn ++ ": " ]
439+ paras $ [ line $ "Multiple FFI implementations have been provided for module " ++ runModuleName mn ++ ": " ]
440440 ++ map (indent . line) paths
441441 goSimple (InvalidExternsFile path) =
442442 paras [ line "Externs file is invalid: "
@@ -461,80 +461,80 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
461461 , indent $ line $ prettyPrintKind ki
462462 ]
463463 goSimple (MultipleFixities name) =
464− line $ "Multiple fixity declarations for " ++ show name
464+ line $ "Multiple fixity declarations for " ++ showIdent name
465465 goSimple (OrphanTypeDeclaration nm) =
466− line $ "Orphan type declaration for " ++ show nm
466+ line $ "Orphan type declaration for " ++ showIdent nm
467467 goSimple (OrphanFixityDeclaration op) =
468468 line $ "Orphan fixity declaration for " ++ show op
469469 goSimple (RedefinedModule name filenames) =
470− paras $ [ line $ "Module " ++ show name ++ " has been defined multiple times:"
471− ] ++ map (indent . line . displaySourceSpan) filenames
470+ paras $ line ("Module " ++ runModuleName name ++ " has been defined multiple times:")
471+ : map (indent . line . displaySourceSpan) filenames
472472 goSimple (RedefinedIdent name) =
473− line $ "Name " ++ show name ++ " has been defined multiple times"
473+ line $ "Name " ++ showIdent name ++ " has been defined multiple times"
474474 goSimple (UnknownModule mn) =
475− line $ "Unknown module " ++ show mn
475+ line $ "Unknown module " ++ runModuleName mn
476476 goSimple (UnknownType name) =
477− line $ "Unknown type " ++ show name
477+ line $ "Unknown type " ++ showQualified runProperName name
478478 goSimple (UnknownTypeClass name) =
479− line $ "Unknown type class " ++ show name
479+ line $ "Unknown type class " ++ showQualified runProperName name
480480 goSimple (UnknownValue name) =
481− line $ "Unknown value " ++ show name
481+ line $ "Unknown value " ++ showQualified showIdent name
482482 goSimple (UnknownTypeConstructor name) =
483− line $ "Unknown type constructor " ++ show name
483+ line $ "Unknown type constructor " ++ showQualified runProperName name
484484 goSimple (UnknownDataConstructor dc tc) =
485− line $ "Unknown data constructor " ++ show dc ++ foldMap ((" for type constructor " ++) . show) tc
485+ line $ "Unknown data constructor " ++ showQualified runProperName dc ++ foldMap ((" for type constructor " ++) . showQualified runProperName) tc
486486 goSimple (UnknownImportType mn name) =
487− line $ "Module " ++ show mn ++ " does not export type " ++ show name
487+ line $ "Module " ++ runModuleName mn ++ " does not export type " ++ runProperName name
488488 goSimple (UnknownExportType name) =
489− line $ "Cannot export unknown type " ++ show name
489+ line $ "Cannot export unknown type " ++ runProperName name
490490 goSimple (UnknownImportTypeClass mn name) =
491− line $ "Module " ++ show mn ++ " does not export type class " ++ show name
491+ line $ "Module " ++ runModuleName mn ++ " does not export type class " ++ runProperName name
492492 goSimple (UnknownExportTypeClass name) =
493− line $ "Cannot export unknown type class " ++ show name
493+ line $ "Cannot export unknown type class " ++ runProperName name
494494 goSimple (UnknownImportValue mn name) =
495− line $ "Module " ++ show mn ++ " does not export value " ++ show name
495+ line $ "Module " ++ runModuleName mn ++ " does not export value " ++ showIdent name
496496 goSimple (UnknownExportValue name) =
497− line $ "Cannot export unknown value " ++ show name
497+ line $ "Cannot export unknown value " ++ showIdent name
498498 goSimple (UnknownExportModule name) =
499− line $ "Cannot export unknown module " ++ show name ++ ", it either does not exist or has not been imported by the current module"
499+ line $ "Cannot export unknown module " ++ runModuleName name ++ ", it either does not exist or has not been imported by the current module"
500500 goSimple (UnknownImportDataConstructor mn tcon dcon) =
501− line $ "Module " ++ show mn ++ " does not export data constructor " ++ show dcon ++ " for type " ++ show tcon
501+ line $ "Module " ++ runModuleName mn ++ " does not export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon
502502 goSimple (UnknownExportDataConstructor tcon dcon) =
503− line $ "Cannot export data constructor " ++ show dcon ++ " for type " ++ show tcon ++ " as it has not been declared"
503+ line $ "Cannot export data constructor " ++ runProperName dcon ++ " for type " ++ runProperName tcon ++ " as it has not been declared"
504504 goSimple (ConflictingImport nm mn) =
505− line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ show mn
505+ line $ "Cannot declare " ++ show nm ++ " since another declaration of that name was imported from " ++ runModuleName mn
506506 goSimple (ConflictingImports nm m1 m2) =
507− line $ "Conflicting imports for " ++ nm ++ " from modules " ++ show m1 ++ " and " ++ show m2
507+ line $ "Conflicting imports for " ++ nm ++ " from modules " ++ runModuleName m1 ++ " and " ++ runModuleName m2
508508 goSimple (ConflictingTypeDecls nm) =
509− line $ "Conflicting type declarations for " ++ show nm
509+ line $ "Conflicting type declarations for " ++ runProperName nm
510510 goSimple (ConflictingCtorDecls nm) =
511− line $ "Conflicting data constructor declarations for " ++ show nm
511+ line $ "Conflicting data constructor declarations for " ++ runProperName nm
512512 goSimple (TypeConflictsWithClass nm) =
513− line $ "Type " ++ show nm ++ " conflicts with type class declaration of the same name"
513+ line $ "Type " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
514514 goSimple (CtorConflictsWithClass nm) =
515− line $ "Data constructor " ++ show nm ++ " conflicts with type class declaration of the same name"
515+ line $ "Data constructor " ++ runProperName nm ++ " conflicts with type class declaration of the same name"
516516 goSimple (ClassConflictsWithType nm) =
517− line $ "Type class " ++ show nm ++ " conflicts with type declaration of the same name"
517+ line $ "Type class " ++ runProperName nm ++ " conflicts with type declaration of the same name"
518518 goSimple (ClassConflictsWithCtor nm) =
519− line $ "Type class " ++ show nm ++ " conflicts with data constructor declaration of the same name"
519+ line $ "Type class " ++ runProperName nm ++ " conflicts with data constructor declaration of the same name"
520520 goSimple (DuplicateClassExport nm) =
521− line $ "Duplicate export declaration for type class " ++ show nm
521+ line $ "Duplicate export declaration for type class " ++ runProperName nm
522522 goSimple (DuplicateValueExport nm) =
523− line $ "Duplicate export declaration for value " ++ show nm
523+ line $ "Duplicate export declaration for value " ++ showIdent nm
524524 goSimple (CycleInDeclaration nm) =
525− line $ "Cycle in declaration of " ++ show nm
525+ line $ "Cycle in declaration of " ++ showIdent nm
526526 goSimple (CycleInModules mns) =
527− line $ "Cycle in module dependencies: " ++ intercalate ", " (map show mns)
527+ line $ "Cycle in module dependencies: " ++ intercalate ", " (map runModuleName mns)
528528 goSimple (CycleInTypeSynonym pn) =
529− line $ "Cycle in type synonym" ++ foldMap ((" " ++) . show) pn
529+ line $ "Cycle in type synonym" ++ foldMap ((" " ++) . runProperName) pn
530530 goSimple (NameIsUndefined ident) =
531− line $ show ident ++ " is undefined"
531+ line $ showIdent ident ++ " is undefined"
532532 goSimple (NameNotInScope ident) =
533− line $ show ident ++ " may not be defined in the current scope"
533+ line $ showIdent ident ++ " may not be defined in the current scope"
534534 goSimple (UndefinedTypeVariable name) =
535− line $ "Type variable " ++ show name ++ " is undefined"
535+ line $ "Type variable " ++ runProperName name ++ " is undefined"
536536 goSimple (PartiallyAppliedSynonym name) =
537− paras [ line $ "Partially applied type synonym " ++ show name
537+ paras [ line $ "Partially applied type synonym " ++ showQualified runProperName name
538538 , line "Type synonyms must be applied to all of their type arguments."
539539 ]
540540 goSimple (EscapedSkolem binding) =
@@ -561,18 +561,18 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
561561 , indent $ line $ prettyPrintType t2
562562 ]
563563 goSimple (OverlappingInstances nm ts (d : ds)) =
564− paras [ line $ "Overlapping instances found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
565− , indent $ paras (line (show d ++ " (chosen)") : map (line . show) ds)
564+ paras [ line $ "Overlapping instances found for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
565+ , indent $ paras (line (showQualified showIdent d ++ " (chosen)") : map (line . showQualified showIdent) ds)
566566 ]
567567 goSimple OverlappingInstances{} = error "OverlappingInstances: empty instance list"
568568 goSimple (NoInstanceFound nm ts) =
569− line $ "No instance found for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
569+ line $ "No instance found for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts)
570570 goSimple (PossiblyInfiniteInstance nm ts) =
571− line $ "Instance for " ++ show nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is possibly infinite."
571+ line $ "Instance for " ++ showQualified runProperName nm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is possibly infinite."
572572 goSimple (CannotDerive nm ts) =
573− line $ "Cannot derive " ++ show nm ++ " instance for " ++ unwords (map prettyPrintTypeAtom ts)
573+ line $ "Cannot derive " ++ showQualified runProperName nm ++ " instance for " ++ unwords (map prettyPrintTypeAtom ts)
574574 goSimple (CannotFindDerivingType nm) =
575− line $ "Cannot derive instance, because the type declaration for " ++ show nm ++ " could not be found."
575+ line $ "Cannot derive instance, because the type declaration for " ++ runProperName nm ++ " could not be found."
576576 goSimple (DuplicateLabel l expr) =
577577 paras $ [ line $ "Duplicate label " ++ show l ++ " in row." ]
578578 <> foldMap (\expr' -> [ line "Relevant expression: "
@@ -581,22 +581,22 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
581581 goSimple (DuplicateTypeArgument name) =
582582 line $ "Duplicate type argument " ++ show name
583583 goSimple (DuplicateValueDeclaration nm) =
584− line $ "Duplicate value declaration for " ++ show nm
584+ line $ "Duplicate value declaration for " ++ showIdent nm
585585 goSimple (ArgListLengthsDiffer ident) =
586− line $ "Argument list lengths differ in declaration " ++ show ident
586+ line $ "Argument list lengths differ in declaration " ++ showIdent ident
587587 goSimple (OverlappingArgNames ident) =
588− line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . show) ident
588+ line $ "Overlapping names in function/binder" ++ foldMap ((" in declaration" ++) . showIdent) ident
589589 goSimple (MissingClassMember ident) =
590− line $ "Member " ++ show ident ++ " has not been implemented"
590+ line $ "Member " ++ showIdent ident ++ " has not been implemented"
591591 goSimple (ExtraneousClassMember ident) =
592− line $ "Member " ++ show ident ++ " is not a member of the class being instantiated"
592+ line $ "Member " ++ showIdent ident ++ " is not a member of the class being instantiated"
593593 goSimple (ExpectedType ty kind) =
594594 paras [ line "In a type-annotated expression x :: t, the type t must have kind *."
595595 , line $ "The error arises from the type " ++ prettyPrintType ty ++ " having the kind " ++ prettyPrintKind kind ++ " instead."
596596 ]
597597 goSimple (IncorrectConstructorArity nm) =
598− line $ "Wrong number of arguments to constructor " ++ show nm
599− goSimple SubsumptionCheckFailed = line $ "Unable to check type subsumption"
598+ line $ "Wrong number of arguments to constructor " ++ showQualified runProperName nm
599+ goSimple SubsumptionCheckFailed = line "Unable to check type subsumption"
600600 goSimple (ExprDoesNotHaveType expr ty) =
601601 paras [ line "Expression"
602602 , indent $ line $ prettyPrintValue expr
@@ -614,7 +614,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
614614 goSimple TypeSynonymInstance =
615615 line "Type synonym instances are disallowed"
616616 goSimple (OrphanInstance nm cnm ts) =
617− paras [ line $ "Instance " ++ show nm ++ " for " ++ show cnm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is an orphan instance."
617+ paras [ line $ "Instance " ++ showIdent nm ++ " for " ++ showQualified runProperName cnm ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ " is an orphan instance."
618618 , line "An orphan instance is an instance which is defined in neither the class module nor the data type module."
619619 , line "Consider moving the instance, if possible, or using a newtype wrapper."
620620 ]
@@ -625,19 +625,19 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
625625 , indent $ line $ prettyPrintType ty
626626 ]
627627 goSimple (TransitiveExportError x ys) =
628− paras $ (line $ "An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
628+ paras $ line ("An export for " ++ prettyPrintExport x ++ " requires the following to also be exported: ")
629629 : map (line . prettyPrintExport) ys
630630 goSimple (ShadowedName nm) =
631− line $ "Name '" ++ show nm ++ "' was shadowed."
631+ line $ "Name '" ++ showIdent nm ++ "' was shadowed."
632632 goSimple (ClassOperator className opName) =
633− paras [ line $ "Class '" ++ show className ++ "' declares operator " ++ show opName ++ "."
634− , indent $ line $ "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
635− , indent $ line $ show opName ++ " = someMember"
633+ paras [ line $ "Class '" ++ runProperName className ++ "' declares operator " ++ showIdent opName ++ "."
634+ , indent $ line "This may be disallowed in the future - consider declaring a named member in the class and making the operator an alias:"
635+ , indent $ line $ showIdent opName ++ " = someMember"
636636 ]
637637 goSimple (MisleadingEmptyTypeImport mn name) =
638− line $ "Importing type " ++ show name ++ "(..) from " ++ show mn ++ " is misleading as it has no exported data constructors"
638+ line $ "Importing type " ++ runProperName name ++ "(..) from " ++ runModuleName mn ++ " is misleading as it has no exported data constructors"
639639 goSimple (ImportHidingModule name) =
640− line $ "Attempted to hide module " ++ show name ++ " in import expression, this is not permitted"
640+ line $ "Attempted to hide module " ++ runModuleName name ++ " in import expression, this is not permitted"
641641 goSimple (WildcardInferredType ty) =
642642 line $ "The wildcard type definition has the inferred type " ++ prettyPrintType ty
643643 goSimple (NotExhaustivePattern bs b) =
@@ -652,7 +652,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
652652 ] ++
653653 [ line "..." | not b ]
654654 go (NotYetDefined names err) =
655− paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map show names) ++ ":"
655+ paras [ line $ "The following are not yet defined here: " ++ intercalate ", " (map showIdent names) ++ ":"
656656 , indent $ go err
657657 ]
658658 go (ErrorUnifyingTypes t1 t2 err) =
@@ -668,7 +668,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
668668 , go err
669669 ]
670670 go (ErrorInModule mn err) =
671− paras [ lineWithLevel $ "in module " ++ show mn ++ ":"
671+ paras [ lineWithLevel $ "in module " ++ runModuleName mn ++ ":"
672672 , go err
673673 ]
674674 go (ErrorInSubsumption t1 t2 err) =
@@ -679,7 +679,7 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
679679 , go err
680680 ]
681681 go (ErrorInInstance name ts err) =
682− paras [ lineWithLevel $ "in type class instance " ++ show name ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
682+ paras [ lineWithLevel $ "in type class instance " ++ showQualified runProperName name ++ " " ++ unwords (map prettyPrintTypeAtom ts) ++ ":"
683683 , go err
684684 ]
685685 go (ErrorCheckingKind ty err) =
@@ -709,15 +709,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
709709 , go err
710710 ]
711711 go (ErrorInDataConstructor nm err) =
712− paras [ lineWithLevel $ "in data constructor " ++ show nm ++ ":"
712+ paras [ lineWithLevel $ "in data constructor " ++ runProperName nm ++ ":"
713713 , go err
714714 ]
715715 go (ErrorInTypeConstructor nm err) =
716− paras [ lineWithLevel $ "in type constructor " ++ show nm ++ ":"
716+ paras [ lineWithLevel $ "in type constructor " ++ runProperName nm ++ ":"
717717 , go err
718718 ]
719719 go (ErrorInBindingGroup nms err) =
720− paras [ lineWithLevel $ "in binding group " ++ intercalate ", " (map show nms) ++ ":"
720+ paras [ lineWithLevel $ "in binding group " ++ intercalate ", " (map showIdent nms) ++ ":"
721721 , go err
722722 ]
723723 go (ErrorInDataBindingGroup err) =
@@ -725,15 +725,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
725725 , go err
726726 ]
727727 go (ErrorInTypeSynonym name err) =
728− paras [ lineWithLevel $ "in type synonym " ++ show name ++ ":"
728+ paras [ lineWithLevel $ "in type synonym " ++ runProperName name ++ ":"
729729 , go err
730730 ]
731731 go (ErrorInValueDeclaration n err) =
732− paras [ lineWithLevel $ "in value declaration " ++ show n ++ ":"
732+ paras [ lineWithLevel $ "in value declaration " ++ showIdent n ++ ":"
733733 , go err
734734 ]
735735 go (ErrorInForeignImport nm err) =
736− paras [ lineWithLevel $ "in foreign import " ++ show nm ++ ":"
736+ paras [ lineWithLevel $ "in foreign import " ++ showIdent nm ++ ":"
737737 , go err
738738 ]
739739 go (PositionedError srcSpan err) =
@@ -753,8 +753,8 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
753753 suggestions :: ErrorMessage -> [Box.Box]
754754 suggestions = suggestions' . unwrapErrorMessage
755755 where
756− suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ show im ++ ":"
757− , indent . line $ "import " ++ show im ++ " hiding (" ++ nm ++ ")"
756+ suggestions' (ConflictingImport nm im) = [ line $ "Possible fix: hide " ++ show nm ++ " when importing " ++ runModuleName im ++ ":"
757+ , indent . line $ "import " ++ runModuleName im ++ " hiding (" ++ nm ++ ")"
758758 ]
759759 suggestions' (TypesDoNotUnify t1 t2)
760760 | isObject t1 && isFunction t2 = [line "Note that function composition in PureScript is defined using (<<<)"]
@@ -768,11 +768,11 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
768768 -- Pretty print and export declaration
769769 --
770770 prettyPrintExport :: DeclarationRef -> String
771− prettyPrintExport (TypeRef pn _) = show pn
772− prettyPrintExport (ValueRef ident) = show ident
773− prettyPrintExport (TypeClassRef pn) = show pn
774− prettyPrintExport (TypeInstanceRef ident) = show ident
775− prettyPrintExport (ModuleRef name) = "module " ++ show name
771+ prettyPrintExport (TypeRef pn _) = runProperName pn
772+ prettyPrintExport (ValueRef ident) = showIdent ident
773+ prettyPrintExport (TypeClassRef pn) = runProperName pn
774+ prettyPrintExport (TypeInstanceRef ident) = showIdent ident
775+ prettyPrintExport (ModuleRef name) = "module " ++ runModuleName name
776776 prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
777777
778778 -- |