+badImportItemErrDataCon :: OccName -> ModIface -> ImpDeclSpec -> IE RdrName -> SDoc
+badImportItemErrDataCon dataType iface decl_spec ie
+ = vcat [ ptext (sLit "In module")
+ <+> quotes (ppr (is_mod decl_spec))
+ <+> source_import <> colon
+ , nest 2 $ quotes datacon
+ <+> ptext (sLit "is a data constructor of")
+ <+> quotes (ppr dataType)
+ , ptext (sLit "To import it use")
+ , nest 2 $ quotes (ptext (sLit "import")
+ <+> ppr (is_mod decl_spec)
+ <+> parens (ppr dataType <+> parens datacon))
+ , ptext (sLit "or")
+ , nest 2 $ quotes (ptext (sLit "import")
+ <+> ppr (is_mod decl_spec)
+ <+> parens (ppr dataType <+> parens (ptext $ sLit "..")))
+ ]
+ where
+ datacon = ppr . rdrNameOcc $ ieName ie
+ source_import | mi_boot iface = ptext (sLit "(hi-boot interface)")
+ | otherwise = empty
+
+badImportItemErr :: ModIface -> ImpDeclSpec -> IE RdrName -> [AvailInfo] -> SDoc
+badImportItemErr iface decl_spec ie avails
+ = case find checkIfDataCon avails of
+ Just con -> badImportItemErrDataCon (availOccName con) iface decl_spec ie
+ Nothing -> badImportItemErrStd iface decl_spec ie
+ where
+ checkIfDataCon (AvailTC _ ns) =
+ case find (\n -> importedFS == nameOccNameFS n) ns of
+ Just n -> isDataConName n
+ Nothing -> False
+ checkIfDataCon _ = False
+ availOccName = nameOccName . availName
+ nameOccNameFS = occNameFS . nameOccName
+ importedFS = occNameFS . rdrNameOcc $ ieName ie
+