@@ -143,6 +143,9 @@ data SimpleErrorMessage
143 | UnusedDctorImport ProperName
143 | UnusedDctorImport ProperName
144 | UnusedDctorExplicitImport ProperName [ProperName]
144 | UnusedDctorExplicitImport ProperName [ProperName]
145 | DeprecatedQualifiedSyntax ModuleName ModuleName
145 | DeprecatedQualifiedSyntax ModuleName ModuleName
146+ | RedundantUnqualifiedImport ModuleName ImportDeclarationType
147+ | DuplicateSelectiveImport ModuleName
148+ | DuplicateImport ModuleName ImportDeclarationType (Maybe ModuleName)
146 deriving (Show)
149 deriving (Show)
148-- | Error message hints, providing more detailed information about failure.
151-- | Error message hints, providing more detailed information about failure.
@@ -278,6 +281,9 @@ errorCode em = case unwrapErrorMessage em of
278 UnusedDctorImport{} -> "UnusedDctorImport"
281 UnusedDctorImport{} -> "UnusedDctorImport"
279 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
282 UnusedDctorExplicitImport{} -> "UnusedDctorExplicitImport"
280 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
283 DeprecatedQualifiedSyntax{} -> "DeprecatedQualifiedSyntax"
284+ RedundantUnqualifiedImport{} -> "RedundantUnqualifiedImport"
285+ DuplicateSelectiveImport{} -> "DuplicateSelectiveImport"
286+ DuplicateImport{} -> "DuplicateImport"
@@ -747,6 +753,15 @@ prettyPrintSingleError full level e = do
747 paras [ line $ "The import of type " ++ runModuleName name ++ " as " ++ runModuleName qualName ++ " uses the deprecated 'import qualified' syntax."
753 paras [ line $ "The import of type " ++ runModuleName name ++ " as " ++ runModuleName qualName ++ " uses the deprecated 'import qualified' syntax."
748 , line $ "This syntax form will be removed in PureScript 0.9." ]
754 , line $ "This syntax form will be removed in PureScript 0.9." ]
756+ renderSimpleErrorMessage (RedundantUnqualifiedImport name imp) =
757+ line $ "Import of " ++ prettyPrintImport name imp Nothing ++ " is redundant due to a whole-module import"
759+ renderSimpleErrorMessage (DuplicateSelectiveImport name) =
760+ line $ "There is an existing import of " ++ runModuleName name ++ ", consider merging the import lists"
762+ renderSimpleErrorMessage (DuplicateImport name imp qual) =
763+ line $ "Duplicate import of " ++ prettyPrintImport name imp qual
750 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
765 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
751 renderHint (ErrorUnifyingTypes t1 t2) detail =
766 renderHint (ErrorUnifyingTypes t1 t2) detail =
752 paras [ detail
767 paras [ detail
@@ -878,11 +893,24 @@ prettyPrintSingleError full level e = do
878 -- Pretty print and export declaration
893 -- Pretty print and export declaration
879 prettyPrintExport :: DeclarationRef -> String
894 prettyPrintExport :: DeclarationRef -> String
880 prettyPrintExport (TypeRef pn _) = runProperName pn
895 prettyPrintExport (TypeRef pn _) = runProperName pn
896+ prettyPrintExport ref = prettyPrintRef ref
898+ prettyPrintRef :: DeclarationRef -> String
899+ prettyPrintRef (TypeRef pn Nothing) = runProperName pn ++ "(..)"
900+ prettyPrintRef (TypeRef pn (Just dctors)) = runProperName pn ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
881− prettyPrintExport (ValueRef ident) = showIdent ident
901+ prettyPrintRef (ValueRef ident) = showIdent ident
882− prettyPrintExport (TypeClassRef pn) = runProperName pn
902+ prettyPrintRef (TypeClassRef pn) = runProperName pn
883− prettyPrintExport (TypeInstanceRef ident) = showIdent ident
903+ prettyPrintRef (TypeInstanceRef ident) = showIdent ident
884− prettyPrintExport (ModuleRef name) = "module " ++ runModuleName name
904+ prettyPrintRef (ModuleRef name) = "module " ++ runModuleName name
885− prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
905+ prettyPrintRef (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
907+ prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> String
908+ prettyPrintImport mn idt qual =
910+ Implicit -> runModuleName mn
911+ Explicit refs -> runModuleName mn ++ " (" ++ intercalate ", " (map prettyPrintRef refs) ++ ")"
912+ Hiding refs -> runModuleName mn ++ " hiding (" ++ intercalate "," (map prettyPrintRef refs) ++ ")"
913+ in i ++ maybe "" (\q -> " as " ++ runModuleName q) qual
887 -- | Simplify an error message
915 -- | Simplify an error message
888 simplifyErrorMessage :: ErrorMessage -> ErrorMessage
916 simplifyErrorMessage :: ErrorMessage -> ErrorMessage