@@ -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"
@@ -718,6 +724,15 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
718 paras [ line $ "The import of type " ++ runModuleName name ++ " as " ++ runModuleName qualName ++ " uses the deprecated 'import qualified' syntax."
724 paras [ line $ "The import of type " ++ runModuleName name ++ " as " ++ runModuleName qualName ++ " uses the deprecated 'import qualified' syntax."
719 , line $ "This syntax form will be removed in PureScript 0.9." ]
725 , line $ "This syntax form will be removed in PureScript 0.9." ]
727+ renderSimpleErrorMessage (RedundantUnqualifiedImport name imp) =
728+ line $ "Import of " ++ prettyPrintImport name imp Nothing ++ " is redundant due to a whole-module import"
730+ renderSimpleErrorMessage (DuplicateSelectiveImport name) =
731+ line $ "There is an existing import of " ++ runModuleName name ++ ", consider merging the import lists"
733+ renderSimpleErrorMessage (DuplicateImport name imp qual) =
734+ line $ "Duplicate import of " ++ prettyPrintImport name imp qual
721 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
736 renderHint :: ErrorMessageHint -> Box.Box -> Box.Box
722 renderHint (ErrorUnifyingTypes t1 t2) detail =
737 renderHint (ErrorUnifyingTypes t1 t2) detail =
723 paras [ detail
738 paras [ detail
@@ -849,11 +864,24 @@ prettyPrintSingleError full level e = prettyPrintErrorMessage <$> onTypesInError
849 -- Pretty print and export declaration
864 -- Pretty print and export declaration
850 prettyPrintExport :: DeclarationRef -> String
865 prettyPrintExport :: DeclarationRef -> String
851 prettyPrintExport (TypeRef pn _) = runProperName pn
866 prettyPrintExport (TypeRef pn _) = runProperName pn
867+ prettyPrintExport ref = prettyPrintRef ref
869+ prettyPrintRef :: DeclarationRef -> String
870+ prettyPrintRef (TypeRef pn Nothing) = runProperName pn ++ "(..)"
871+ prettyPrintRef (TypeRef pn (Just dctors)) = runProperName pn ++ "(" ++ intercalate ", " (map runProperName dctors) ++ ")"
852− prettyPrintExport (ValueRef ident) = showIdent ident
872+ prettyPrintRef (ValueRef ident) = showIdent ident
853− prettyPrintExport (TypeClassRef pn) = runProperName pn
873+ prettyPrintRef (TypeClassRef pn) = runProperName pn
854− prettyPrintExport (TypeInstanceRef ident) = showIdent ident
874+ prettyPrintRef (TypeInstanceRef ident) = showIdent ident
855− prettyPrintExport (ModuleRef name) = "module " ++ runModuleName name
875+ prettyPrintRef (ModuleRef name) = "module " ++ runModuleName name
856− prettyPrintExport (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
876+ prettyPrintRef (PositionedDeclarationRef _ _ ref) = prettyPrintExport ref
878+ prettyPrintImport :: ModuleName -> ImportDeclarationType -> Maybe ModuleName -> String
879+ prettyPrintImport mn idt qual =
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
858 -- | Simplify an error message
886 -- | Simplify an error message
859 simplifyErrorMessage :: ErrorMessage -> ErrorMessage
887 simplifyErrorMessage :: ErrorMessage -> ErrorMessage