@@ -143,6 +143,9 @@ data SimpleErrorMessage
143143 | UnusedDctorImport ProperName
144144 | UnusedDctorExplicitImport ProperName [ProperName]
145145 | DeprecatedQualifiedSyntax ModuleName ModuleName
146+ | RedundantUnqualifiedImport ModuleName ImportDeclarationType
147+ | DuplicateSelectiveImport ModuleName
148+ | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
146149 deriving (Show)
147150
148151-- | Error message hints, providing more detailed information about failure.
@@ -278,6 +281,9 @@ errorCode em = case unwrapErrorMessage em of
278281 UnusedDctorImport{} -> "UnusedDctorImport"
279282 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
280283 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
284+ RedundantUnqualifiedImport{} -> "RedundantUnqualifiedImport"
285+ DuplicateSelectiveImport{} -> "DuplicateSelectiveImport"
286+ DuplicateImport{} -> "DuplicateImport"
281287
282288
283289-- |
@@ -718,6 +724,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
718724 paras [ line $ "The import of type " ++ runModuleName name ++ " as " ++ runModuleName qualName ++ " uses the deprecated 'import qualified' syntax."
719725 , line $ "This syntax form will be removed in PureScript 0.9." ]
720726
727+ renderSimpleErrorMessage (RedundantUnqualifiedImport name imp) =
728+ line $ "Import of " ++ prettyPrintImport name imp Nothing ++ " is redundant due to a whole-module import"
729+
730+ renderSimpleErrorMessage (DuplicateSelectiveImport name) =
731+ line $ "There is an existing import of " ++ runModuleName name ++ ", consider merging the import lists"
732+
733+ renderSimpleErrorMessage (DuplicateImport name imp qual) =
734+ line $ "Duplicate import of " ++ prettyPrintImport name imp qual
735+
721736 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
722737 renderHint (ErrorUnifyingTypes t1 t2) detail =
723738 paras [ detail
@@ -849,11 +864,24 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
849864 -- Pretty print and export declaration
850865 prettyPrintExport :: DeclarationRef -> String
851866 prettyPrintExport (TypeRef pn _) = runProperName pn
852− prettyPrintExport (ValueRef ident) = showIdent ident
853− prettyPrintExport (TypeClassRef pn) = runProperName pn
854− prettyPrintExport (TypeInstanceRef ident) = showIdent ident
855− prettyPrintExport (ModuleRef name) = "module " ++ runModuleName name
856− prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
867+ prettyPrintExport ref = prettyPrintRef ref
868+
869+ prettyPrintRef :: DeclarationRef -> String
870+ prettyPrintRef (TypeRef pn Nothing) = runProperName pn ++ "(..)"
871+ prettyPrintRef (TypeRef pn (Just dctors)) = runProperName pn ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
872+ prettyPrintRef (ValueRef ident) = showIdent ident
873+ prettyPrintRef (TypeClassRef pn) = runProperName pn
874+ prettyPrintRef (TypeInstanceRef ident) = showIdent ident
875+ prettyPrintRef (ModuleRef name) = "module " ++ runModuleName name
876+ prettyPrintRef (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
877+
878+ prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> String
879+ prettyPrintImport mn idt qual =
880+ let i = case idt of
881+ Implicit -> runModuleName mn
882+ Explicit refs -> runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")"
883+ Hiding refs -> runModuleName mn ++ " hiding (" ++ intercalate "," (map prettyPrintRef refs) ++ ")"
884+ in i ++ maybe "" (\q -> " as " ++ runModuleName q) qual
857885
858886 -- | Simplify an error message
859887 simplifyErrorMessage :: ErrorMessage -> ErrorMessage