X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2Fmain%2FFinder.lhs;h=21d7febd447e72a1fd0904ea8f702b7ec2a1094b;hb=a1d8f7e9ead3ea284abf878ed3015a84eb5d67fb;hp=1d43591acd720a0f8c899ce41eb515f58e59d3d7;hpb=8844513929ccd58854227ddb6275095a1f1742ad;p=ghc-hetmet.git diff --git a/compiler/main/Finder.lhs b/compiler/main/Finder.lhs index 1d43591..21d7feb 100644 --- a/compiler/main/Finder.lhs +++ b/compiler/main/Finder.lhs @@ -10,6 +10,7 @@ module Finder ( findImportedModule, findExactModule, findHomeModule, + findExposedPackageModule, mkHomeModLocation, mkHomeModLocation2, mkHiOnlyModLocation, @@ -31,18 +32,17 @@ import Packages import FastString import Util import PrelNames ( gHC_PRIM ) -import DynFlags ( DynFlags(..), isOneShot, GhcMode(..) ) +import DynFlags import Outputable import FiniteMap import LazyUniqFM import Maybes ( expectJust ) +import Distribution.Text import Distribution.Package hiding (PackageId) import Data.IORef ( IORef, writeIORef, readIORef, modifyIORef ) -import Data.List import System.Directory import System.FilePath -import System.IO import Control.Monad import System.Time ( ClockTime ) @@ -181,10 +181,10 @@ findExposedPackageModule hsc_env mod_name mb_pkg | null found_exposed = return (NotFound [] Nothing mod_hiddens pkg_hiddens) -- found in just one exposed package: | [(pkg_conf, _)] <- found_exposed - = let pkgid = mkPackageId (package pkg_conf) in + = let pkgid = packageConfigId pkg_conf in findPackageModule_ hsc_env (mkModule pkgid mod_name) pkg_conf | otherwise - = return (FoundMultiple (map (mkPackageId.package.fst) found_exposed)) + = return (FoundMultiple (map (packageConfigId.fst) found_exposed)) where dflags = hsc_dflags hsc_env found = lookupModuleInAllPackages dflags mod_name @@ -197,10 +197,10 @@ findExposedPackageModule hsc_env mod_name mb_pkg is_exposed (pkg_conf,exposed_mod) = exposed pkg_conf && exposed_mod - mod_hiddens = [ mkPackageId (package pkg_conf) + mod_hiddens = [ packageConfigId pkg_conf | (pkg_conf,False) <- found ] - pkg_hiddens = [ mkPackageId (package pkg_conf) + pkg_hiddens = [ packageConfigId pkg_conf | (pkg_conf,_) <- found, not (exposed pkg_conf) ] _pkg_conf `matches` Nothing = True @@ -534,17 +534,20 @@ findObjectLinkable mod obj_fn obj_time = do cannotFindModule :: DynFlags -> ModuleName -> FindResult -> SDoc cannotFindModule = cantFindErr (sLit "Could not find module") + (sLit "Ambiguous module name") cannotFindInterface :: DynFlags -> ModuleName -> FindResult -> SDoc cannotFindInterface = cantFindErr (sLit "Failed to load interface for") + (sLit "Ambiguous interface for") -cantFindErr :: LitString -> DynFlags -> ModuleName -> FindResult -> SDoc -cantFindErr cannot_find _dflags mod_name (FoundMultiple pkgs) - = hang (ptext cannot_find <+> quotes (ppr mod_name) <> colon) 2 ( +cantFindErr :: LitString -> LitString -> DynFlags -> ModuleName -> FindResult + -> SDoc +cantFindErr _ multiple_found _ mod_name (FoundMultiple pkgs) + = hang (ptext multiple_found <+> quotes (ppr mod_name) <> colon) 2 ( sep [ptext (sLit "it was found in multiple packages:"), hsep (map (text.packageIdString) pkgs)] ) -cantFindErr cannot_find dflags mod_name find_result +cantFindErr cannot_find _ dflags mod_name find_result = hang (ptext cannot_find <+> quotes (ppr mod_name) <> colon) 2 more_info where @@ -597,7 +600,17 @@ cantFindErr cannot_find dflags mod_name find_result hang (ptext (sLit "locations searched:")) 2 $ vcat (map text files) pkg_hidden pkg = - ptext (sLit "it is a member of the hidden package") <+> quotes (ppr pkg) + ptext (sLit "It is a member of the hidden package") <+> quotes (ppr pkg) + <> dot $$ cabal_pkg_hidden_hint pkg + cabal_pkg_hidden_hint pkg + | dopt Opt_BuildingCabalPackage dflags + = case simpleParse (packageIdString pkg) of + Just pid -> + ptext (sLit "Perhaps you need to add") <+> + quotes (text (display (pkgName pid))) <+> + ptext (sLit "to the build-depends in your .cabal file.") + Nothing -> empty + | otherwise = empty mod_hidden pkg = ptext (sLit "it is a hidden module in the package") <+> quotes (ppr pkg)