PageRenderTime 41ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/ghc-7.0.4/compiler/main/Finder.lhs

http://picorec.googlecode.com/
Haskell | 622 lines | 412 code | 104 blank | 106 comment | 23 complexity | 4057428464d0911d15b5a3a100c60b41 MD5 | raw file
Possible License(s): BSD-3-Clause, BSD-2-Clause
  1. %
  2. % (c) The University of Glasgow, 2000-2006
  3. %
  4. \section[Finder]{Module Finder}
  5. \begin{code}
  6. module Finder (
  7. flushFinderCaches,
  8. FindResult(..),
  9. findImportedModule,
  10. findExactModule,
  11. findHomeModule,
  12. findExposedPackageModule,
  13. mkHomeModLocation,
  14. mkHomeModLocation2,
  15. mkHiOnlyModLocation,
  16. addHomeModuleToFinder,
  17. uncacheModule,
  18. mkStubPaths,
  19. findObjectLinkableMaybe,
  20. findObjectLinkable,
  21. cannotFindModule,
  22. cannotFindInterface,
  23. ) where
  24. import Module
  25. import HscTypes
  26. import Packages
  27. import FastString
  28. import Util
  29. import PrelNames ( gHC_PRIM )
  30. import DynFlags
  31. import Outputable
  32. import UniqFM
  33. import Maybes ( expectJust )
  34. import Exception ( evaluate )
  35. import Distribution.Text
  36. import Distribution.Package hiding (PackageId)
  37. import Data.IORef ( IORef, writeIORef, readIORef, atomicModifyIORef )
  38. import System.Directory
  39. import System.FilePath
  40. import Control.Monad
  41. import System.Time ( ClockTime )
  42. type FileExt = String -- Filename extension
  43. type BaseName = String -- Basename of file
  44. -- -----------------------------------------------------------------------------
  45. -- The Finder
  46. -- The Finder provides a thin filesystem abstraction to the rest of
  47. -- the compiler. For a given module, it can tell you where the
  48. -- source, interface, and object files for that module live.
  49. -- It does *not* know which particular package a module lives in. Use
  50. -- Packages.lookupModuleInAllPackages for that.
  51. -- -----------------------------------------------------------------------------
  52. -- The finder's cache
  53. -- remove all the home modules from the cache; package modules are
  54. -- assumed to not move around during a session.
  55. flushFinderCaches :: HscEnv -> IO ()
  56. flushFinderCaches hsc_env = do
  57. -- Ideally the update to both caches be a single atomic operation.
  58. writeIORef fc_ref emptyUFM
  59. flushModLocationCache this_pkg mlc_ref
  60. where
  61. this_pkg = thisPackage (hsc_dflags hsc_env)
  62. fc_ref = hsc_FC hsc_env
  63. mlc_ref = hsc_MLC hsc_env
  64. flushModLocationCache :: PackageId -> IORef ModLocationCache -> IO ()
  65. flushModLocationCache this_pkg ref = do
  66. atomicModifyIORef ref $ \fm -> (filterModuleEnv is_ext fm, ())
  67. _ <- evaluate =<< readIORef ref
  68. return ()
  69. where is_ext mod _ | modulePackageId mod /= this_pkg = True
  70. | otherwise = False
  71. addToFinderCache :: IORef FinderCache -> ModuleName -> FindResult -> IO ()
  72. addToFinderCache ref key val =
  73. atomicModifyIORef ref $ \c -> (addToUFM c key val, ())
  74. addToModLocationCache :: IORef ModLocationCache -> Module -> ModLocation -> IO ()
  75. addToModLocationCache ref key val =
  76. atomicModifyIORef ref $ \c -> (extendModuleEnv c key val, ())
  77. removeFromFinderCache :: IORef FinderCache -> ModuleName -> IO ()
  78. removeFromFinderCache ref key =
  79. atomicModifyIORef ref $ \c -> (delFromUFM c key, ())
  80. removeFromModLocationCache :: IORef ModLocationCache -> Module -> IO ()
  81. removeFromModLocationCache ref key =
  82. atomicModifyIORef ref $ \c -> (delModuleEnv c key, ())
  83. lookupFinderCache :: IORef FinderCache -> ModuleName -> IO (Maybe FindResult)
  84. lookupFinderCache ref key = do
  85. c <- readIORef ref
  86. return $! lookupUFM c key
  87. lookupModLocationCache :: IORef ModLocationCache -> Module
  88. -> IO (Maybe ModLocation)
  89. lookupModLocationCache ref key = do
  90. c <- readIORef ref
  91. return $! lookupModuleEnv c key
  92. -- -----------------------------------------------------------------------------
  93. -- The two external entry points
  94. -- | Locate a module that was imported by the user. We have the
  95. -- module's name, and possibly a package name. Without a package
  96. -- name, this function will use the search path and the known exposed
  97. -- packages to find the module, if a package is specified then only
  98. -- that package is searched for the module.
  99. findImportedModule :: HscEnv -> ModuleName -> Maybe FastString -> IO FindResult
  100. findImportedModule hsc_env mod_name mb_pkg =
  101. case mb_pkg of
  102. Nothing -> unqual_import
  103. Just pkg | pkg == fsLit "this" -> home_import -- "this" is special
  104. | otherwise -> pkg_import
  105. where
  106. home_import = findHomeModule hsc_env mod_name
  107. pkg_import = findExposedPackageModule hsc_env mod_name mb_pkg
  108. unqual_import = home_import
  109. `orIfNotFound`
  110. findExposedPackageModule hsc_env mod_name Nothing
  111. -- | Locate a specific 'Module'. The purpose of this function is to
  112. -- create a 'ModLocation' for a given 'Module', that is to find out
  113. -- where the files associated with this module live. It is used when
  114. -- reading the interface for a module mentioned by another interface,
  115. -- for example (a "system import").
  116. findExactModule :: HscEnv -> Module -> IO FindResult
  117. findExactModule hsc_env mod =
  118. let dflags = hsc_dflags hsc_env in
  119. if modulePackageId mod == thisPackage dflags
  120. then findHomeModule hsc_env (moduleName mod)
  121. else findPackageModule hsc_env mod
  122. -- -----------------------------------------------------------------------------
  123. -- Helpers
  124. orIfNotFound :: IO FindResult -> IO FindResult -> IO FindResult
  125. this `orIfNotFound` or_this = do
  126. res <- this
  127. case res of
  128. NotFound places1 _mb_pkg1 mod_hiddens1 pkg_hiddens1 -> do
  129. res2 <- or_this
  130. case res2 of
  131. NotFound places2 mb_pkg2 mod_hiddens2 pkg_hiddens2 ->
  132. return (NotFound (places1 ++ places2)
  133. mb_pkg2 -- snd arg is the package search
  134. (mod_hiddens1 ++ mod_hiddens2)
  135. (pkg_hiddens1 ++ pkg_hiddens2))
  136. _other -> return res2
  137. _other -> return res
  138. homeSearchCache :: HscEnv -> ModuleName -> IO FindResult -> IO FindResult
  139. homeSearchCache hsc_env mod_name do_this = do
  140. m <- lookupFinderCache (hsc_FC hsc_env) mod_name
  141. case m of
  142. Just result -> return result
  143. Nothing -> do
  144. result <- do_this
  145. addToFinderCache (hsc_FC hsc_env) mod_name result
  146. case result of
  147. Found loc mod -> addToModLocationCache (hsc_MLC hsc_env) mod loc
  148. _other -> return ()
  149. return result
  150. findExposedPackageModule :: HscEnv -> ModuleName -> Maybe FastString
  151. -> IO FindResult
  152. findExposedPackageModule hsc_env mod_name mb_pkg
  153. -- not found in any package:
  154. | null found_exposed = return (NotFound [] Nothing mod_hiddens pkg_hiddens)
  155. -- found in just one exposed package:
  156. | [(pkg_conf, _)] <- found_exposed
  157. = let pkgid = packageConfigId pkg_conf in
  158. findPackageModule_ hsc_env (mkModule pkgid mod_name) pkg_conf
  159. | otherwise
  160. = return (FoundMultiple (map (packageConfigId.fst) found_exposed))
  161. where
  162. dflags = hsc_dflags hsc_env
  163. found = lookupModuleInAllPackages dflags mod_name
  164. for_this_pkg = filter ((`matches` mb_pkg) . fst) found
  165. found_exposed = [ (pkg_conf,exposed_mod)
  166. | x@(pkg_conf,exposed_mod) <- for_this_pkg,
  167. is_exposed x ]
  168. is_exposed (pkg_conf,exposed_mod) = exposed pkg_conf && exposed_mod
  169. mod_hiddens = [ packageConfigId pkg_conf
  170. | (pkg_conf,False) <- found ]
  171. pkg_hiddens = [ packageConfigId pkg_conf
  172. | (pkg_conf,_) <- found, not (exposed pkg_conf) ]
  173. _pkg_conf `matches` Nothing = True
  174. pkg_conf `matches` Just pkg =
  175. case packageName pkg_conf of
  176. PackageName n -> pkg == mkFastString n
  177. modLocationCache :: HscEnv -> Module -> IO FindResult -> IO FindResult
  178. modLocationCache hsc_env mod do_this = do
  179. mb_loc <- lookupModLocationCache mlc mod
  180. case mb_loc of
  181. Just loc -> return (Found loc mod)
  182. Nothing -> do
  183. result <- do_this
  184. case result of
  185. Found loc mod -> addToModLocationCache (hsc_MLC hsc_env) mod loc
  186. _other -> return ()
  187. return result
  188. where
  189. mlc = hsc_MLC hsc_env
  190. addHomeModuleToFinder :: HscEnv -> ModuleName -> ModLocation -> IO Module
  191. addHomeModuleToFinder hsc_env mod_name loc = do
  192. let mod = mkModule (thisPackage (hsc_dflags hsc_env)) mod_name
  193. addToFinderCache (hsc_FC hsc_env) mod_name (Found loc mod)
  194. addToModLocationCache (hsc_MLC hsc_env) mod loc
  195. return mod
  196. uncacheModule :: HscEnv -> ModuleName -> IO ()
  197. uncacheModule hsc_env mod = do
  198. let this_pkg = thisPackage (hsc_dflags hsc_env)
  199. removeFromFinderCache (hsc_FC hsc_env) mod
  200. removeFromModLocationCache (hsc_MLC hsc_env) (mkModule this_pkg mod)
  201. -- -----------------------------------------------------------------------------
  202. -- The internal workers
  203. -- | Search for a module in the home package only.
  204. findHomeModule :: HscEnv -> ModuleName -> IO FindResult
  205. findHomeModule hsc_env mod_name =
  206. homeSearchCache hsc_env mod_name $
  207. let
  208. dflags = hsc_dflags hsc_env
  209. home_path = importPaths dflags
  210. hisuf = hiSuf dflags
  211. mod = mkModule (thisPackage dflags) mod_name
  212. source_exts =
  213. [ ("hs", mkHomeModLocationSearched dflags mod_name "hs")
  214. , ("lhs", mkHomeModLocationSearched dflags mod_name "lhs")
  215. ]
  216. hi_exts = [ (hisuf, mkHiOnlyModLocation dflags hisuf)
  217. , (addBootSuffix hisuf, mkHiOnlyModLocation dflags hisuf)
  218. ]
  219. -- In compilation manager modes, we look for source files in the home
  220. -- package because we can compile these automatically. In one-shot
  221. -- compilation mode we look for .hi and .hi-boot files only.
  222. exts | isOneShot (ghcMode dflags) = hi_exts
  223. | otherwise = source_exts
  224. in
  225. -- special case for GHC.Prim; we won't find it in the filesystem.
  226. -- This is important only when compiling the base package (where GHC.Prim
  227. -- is a home module).
  228. if mod == gHC_PRIM
  229. then return (Found (error "GHC.Prim ModLocation") mod)
  230. else
  231. searchPathExts home_path mod exts
  232. -- | Search for a module in external packages only.
  233. findPackageModule :: HscEnv -> Module -> IO FindResult
  234. findPackageModule hsc_env mod = do
  235. let
  236. dflags = hsc_dflags hsc_env
  237. pkg_id = modulePackageId mod
  238. pkg_map = pkgIdMap (pkgState dflags)
  239. --
  240. case lookupPackage pkg_map pkg_id of
  241. Nothing -> return (NoPackage pkg_id)
  242. Just pkg_conf -> findPackageModule_ hsc_env mod pkg_conf
  243. findPackageModule_ :: HscEnv -> Module -> PackageConfig -> IO FindResult
  244. findPackageModule_ hsc_env mod pkg_conf =
  245. modLocationCache hsc_env mod $
  246. -- special case for GHC.Prim; we won't find it in the filesystem.
  247. if mod == gHC_PRIM
  248. then return (Found (error "GHC.Prim ModLocation") mod)
  249. else
  250. let
  251. dflags = hsc_dflags hsc_env
  252. tag = buildTag dflags
  253. -- hi-suffix for packages depends on the build tag.
  254. package_hisuf | null tag = "hi"
  255. | otherwise = tag ++ "_hi"
  256. mk_hi_loc = mkHiOnlyModLocation dflags package_hisuf
  257. import_dirs = importDirs pkg_conf
  258. -- we never look for a .hi-boot file in an external package;
  259. -- .hi-boot files only make sense for the home package.
  260. in
  261. case import_dirs of
  262. [one] | MkDepend <- ghcMode dflags -> do
  263. -- there's only one place that this .hi file can be, so
  264. -- don't bother looking for it.
  265. let basename = moduleNameSlashes (moduleName mod)
  266. loc <- mk_hi_loc one basename
  267. return (Found loc mod)
  268. _otherwise ->
  269. searchPathExts import_dirs mod [(package_hisuf, mk_hi_loc)]
  270. -- -----------------------------------------------------------------------------
  271. -- General path searching
  272. searchPathExts
  273. :: [FilePath] -- paths to search
  274. -> Module -- module name
  275. -> [ (
  276. FileExt, -- suffix
  277. FilePath -> BaseName -> IO ModLocation -- action
  278. )
  279. ]
  280. -> IO FindResult
  281. searchPathExts paths mod exts
  282. = do result <- search to_search
  283. {-
  284. hPutStrLn stderr (showSDoc $
  285. vcat [text "Search" <+> ppr mod <+> sep (map (text. fst) exts)
  286. , nest 2 (vcat (map text paths))
  287. , case result of
  288. Succeeded (loc, p) -> text "Found" <+> ppr loc
  289. Failed fs -> text "not found"])
  290. -}
  291. return result
  292. where
  293. basename = moduleNameSlashes (moduleName mod)
  294. to_search :: [(FilePath, IO ModLocation)]
  295. to_search = [ (file, fn path basename)
  296. | path <- paths,
  297. (ext,fn) <- exts,
  298. let base | path == "." = basename
  299. | otherwise = path </> basename
  300. file = base <.> ext
  301. ]
  302. search [] = return (NotFound (map fst to_search) (Just (modulePackageId mod))
  303. [] [])
  304. search ((file, mk_result) : rest) = do
  305. b <- doesFileExist file
  306. if b
  307. then do { loc <- mk_result; return (Found loc mod) }
  308. else search rest
  309. mkHomeModLocationSearched :: DynFlags -> ModuleName -> FileExt
  310. -> FilePath -> BaseName -> IO ModLocation
  311. mkHomeModLocationSearched dflags mod suff path basename = do
  312. mkHomeModLocation2 dflags mod (path </> basename) suff
  313. -- -----------------------------------------------------------------------------
  314. -- Constructing a home module location
  315. -- This is where we construct the ModLocation for a module in the home
  316. -- package, for which we have a source file. It is called from three
  317. -- places:
  318. --
  319. -- (a) Here in the finder, when we are searching for a module to import,
  320. -- using the search path (-i option).
  321. --
  322. -- (b) The compilation manager, when constructing the ModLocation for
  323. -- a "root" module (a source file named explicitly on the command line
  324. -- or in a :load command in GHCi).
  325. --
  326. -- (c) The driver in one-shot mode, when we need to construct a
  327. -- ModLocation for a source file named on the command-line.
  328. --
  329. -- Parameters are:
  330. --
  331. -- mod
  332. -- The name of the module
  333. --
  334. -- path
  335. -- (a): The search path component where the source file was found.
  336. -- (b) and (c): "."
  337. --
  338. -- src_basename
  339. -- (a): (moduleNameSlashes mod)
  340. -- (b) and (c): The filename of the source file, minus its extension
  341. --
  342. -- ext
  343. -- The filename extension of the source file (usually "hs" or "lhs").
  344. mkHomeModLocation :: DynFlags -> ModuleName -> FilePath -> IO ModLocation
  345. mkHomeModLocation dflags mod src_filename = do
  346. let (basename,extension) = splitExtension src_filename
  347. mkHomeModLocation2 dflags mod basename extension
  348. mkHomeModLocation2 :: DynFlags
  349. -> ModuleName
  350. -> FilePath -- Of source module, without suffix
  351. -> String -- Suffix
  352. -> IO ModLocation
  353. mkHomeModLocation2 dflags mod src_basename ext = do
  354. let mod_basename = moduleNameSlashes mod
  355. obj_fn <- mkObjPath dflags src_basename mod_basename
  356. hi_fn <- mkHiPath dflags src_basename mod_basename
  357. return (ModLocation{ ml_hs_file = Just (src_basename <.> ext),
  358. ml_hi_file = hi_fn,
  359. ml_obj_file = obj_fn })
  360. mkHiOnlyModLocation :: DynFlags -> Suffix -> FilePath -> String
  361. -> IO ModLocation
  362. mkHiOnlyModLocation dflags hisuf path basename
  363. = do let full_basename = path </> basename
  364. obj_fn <- mkObjPath dflags full_basename basename
  365. return ModLocation{ ml_hs_file = Nothing,
  366. ml_hi_file = full_basename <.> hisuf,
  367. -- Remove the .hi-boot suffix from
  368. -- hi_file, if it had one. We always
  369. -- want the name of the real .hi file
  370. -- in the ml_hi_file field.
  371. ml_obj_file = obj_fn
  372. }
  373. -- | Constructs the filename of a .o file for a given source file.
  374. -- Does /not/ check whether the .o file exists
  375. mkObjPath
  376. :: DynFlags
  377. -> FilePath -- the filename of the source file, minus the extension
  378. -> String -- the module name with dots replaced by slashes
  379. -> IO FilePath
  380. mkObjPath dflags basename mod_basename
  381. = do let
  382. odir = objectDir dflags
  383. osuf = objectSuf dflags
  384. obj_basename | Just dir <- odir = dir </> mod_basename
  385. | otherwise = basename
  386. return (obj_basename <.> osuf)
  387. -- | Constructs the filename of a .hi file for a given source file.
  388. -- Does /not/ check whether the .hi file exists
  389. mkHiPath
  390. :: DynFlags
  391. -> FilePath -- the filename of the source file, minus the extension
  392. -> String -- the module name with dots replaced by slashes
  393. -> IO FilePath
  394. mkHiPath dflags basename mod_basename
  395. = do let
  396. hidir = hiDir dflags
  397. hisuf = hiSuf dflags
  398. hi_basename | Just dir <- hidir = dir </> mod_basename
  399. | otherwise = basename
  400. return (hi_basename <.> hisuf)
  401. -- -----------------------------------------------------------------------------
  402. -- Filenames of the stub files
  403. -- We don't have to store these in ModLocations, because they can be derived
  404. -- from other available information, and they're only rarely needed.
  405. mkStubPaths
  406. :: DynFlags
  407. -> ModuleName
  408. -> ModLocation
  409. -> (FilePath,FilePath,FilePath)
  410. mkStubPaths dflags mod location
  411. = let
  412. stubdir = stubDir dflags
  413. mod_basename = moduleNameSlashes mod
  414. src_basename = dropExtension $ expectJust "mkStubPaths"
  415. (ml_hs_file location)
  416. stub_basename0
  417. | Just dir <- stubdir = dir </> mod_basename
  418. | otherwise = src_basename
  419. stub_basename = stub_basename0 ++ "_stub"
  420. obj = ml_obj_file location
  421. osuf = objectSuf dflags
  422. stub_obj_base = dropTail (length osuf + 1) obj ++ "_stub"
  423. -- NB. not takeFileName, see #3093
  424. in
  425. (stub_basename <.> "c",
  426. stub_basename <.> "h",
  427. stub_obj_base <.> objectSuf dflags)
  428. -- -----------------------------------------------------------------------------
  429. -- findLinkable isn't related to the other stuff in here,
  430. -- but there's no other obvious place for it
  431. findObjectLinkableMaybe :: Module -> ModLocation -> IO (Maybe Linkable)
  432. findObjectLinkableMaybe mod locn
  433. = do let obj_fn = ml_obj_file locn
  434. maybe_obj_time <- modificationTimeIfExists obj_fn
  435. case maybe_obj_time of
  436. Nothing -> return Nothing
  437. Just obj_time -> liftM Just (findObjectLinkable mod obj_fn obj_time)
  438. -- Make an object linkable when we know the object file exists, and we know
  439. -- its modification time.
  440. findObjectLinkable :: Module -> FilePath -> ClockTime -> IO Linkable
  441. findObjectLinkable mod obj_fn obj_time = do
  442. let stub_fn = (dropExtension obj_fn ++ "_stub") <.> "o"
  443. stub_exist <- doesFileExist stub_fn
  444. if stub_exist
  445. then return (LM obj_time mod [DotO obj_fn, DotO stub_fn])
  446. else return (LM obj_time mod [DotO obj_fn])
  447. -- -----------------------------------------------------------------------------
  448. -- Error messages
  449. cannotFindModule :: DynFlags -> ModuleName -> FindResult -> SDoc
  450. cannotFindModule = cantFindErr (sLit "Could not find module")
  451. (sLit "Ambiguous module name")
  452. cannotFindInterface :: DynFlags -> ModuleName -> FindResult -> SDoc
  453. cannotFindInterface = cantFindErr (sLit "Failed to load interface for")
  454. (sLit "Ambiguous interface for")
  455. cantFindErr :: LitString -> LitString -> DynFlags -> ModuleName -> FindResult
  456. -> SDoc
  457. cantFindErr _ multiple_found _ mod_name (FoundMultiple pkgs)
  458. = hang (ptext multiple_found <+> quotes (ppr mod_name) <> colon) 2 (
  459. sep [ptext (sLit "it was found in multiple packages:"),
  460. hsep (map (text.packageIdString) pkgs)]
  461. )
  462. cantFindErr cannot_find _ dflags mod_name find_result
  463. = hang (ptext cannot_find <+> quotes (ppr mod_name) <> colon)
  464. 2 more_info
  465. where
  466. more_info
  467. = case find_result of
  468. NoPackage pkg
  469. -> ptext (sLit "no package matching") <+> quotes (ppr pkg) <+>
  470. ptext (sLit "was found")
  471. NotFound files mb_pkg mod_hiddens pkg_hiddens
  472. | Just pkg <- mb_pkg, pkg /= thisPackage dflags
  473. -> not_found_in_package pkg files
  474. | null files && null mod_hiddens && null pkg_hiddens
  475. -> ptext (sLit "it is not a module in the current program, or in any known package.")
  476. | otherwise
  477. -> vcat (map pkg_hidden pkg_hiddens) $$
  478. vcat (map mod_hidden mod_hiddens) $$
  479. tried_these files
  480. NotFoundInPackage pkg
  481. -> ptext (sLit "it is not in package") <+> quotes (ppr pkg)
  482. _ -> panic "cantFindErr"
  483. build_tag = buildTag dflags
  484. not_found_in_package pkg files
  485. | build_tag /= ""
  486. = let
  487. build = if build_tag == "p" then "profiling"
  488. else "\"" ++ build_tag ++ "\""
  489. in
  490. ptext (sLit "Perhaps you haven't installed the ") <> text build <>
  491. ptext (sLit " libraries for package ") <> quotes (ppr pkg) <> char '?' $$
  492. tried_these files
  493. | otherwise
  494. = ptext (sLit "There are files missing in the ") <> quotes (ppr pkg) <>
  495. ptext (sLit " package,") $$
  496. ptext (sLit "try running 'ghc-pkg check'.") $$
  497. tried_these files
  498. tried_these files
  499. | null files = empty
  500. | verbosity dflags < 3 =
  501. ptext (sLit "Use -v to see a list of the files searched for.")
  502. | otherwise =
  503. hang (ptext (sLit "locations searched:")) 2 $ vcat (map text files)
  504. pkg_hidden pkg =
  505. ptext (sLit "It is a member of the hidden package") <+> quotes (ppr pkg)
  506. <> dot $$ cabal_pkg_hidden_hint pkg
  507. cabal_pkg_hidden_hint pkg
  508. | dopt Opt_BuildingCabalPackage dflags
  509. = case simpleParse (packageIdString pkg) of
  510. Just pid ->
  511. ptext (sLit "Perhaps you need to add") <+>
  512. quotes (text (display (pkgName pid))) <+>
  513. ptext (sLit "to the build-depends in your .cabal file.")
  514. Nothing -> empty
  515. | otherwise = empty
  516. mod_hidden pkg =
  517. ptext (sLit "it is a hidden module in the package") <+> quotes (ppr pkg)
  518. \end{code}