2 % (c) The University of Glasgow, 2000
4 \section{Package manipulation}
10 -- * The PackageConfigMap
11 PackageConfigMap, emptyPackageConfigMap, lookupPackage,
12 extendPackageConfigMap, dumpPackages,
14 -- * Reading the package config, and processing cmdline args
15 PackageIdH(..), isHomePackage,
19 checkForPackageConflicts,
20 lookupModuleInAllPackages,
22 HomeModules, mkHomeModules, isHomeModule,
24 -- * Inspecting the set of packages in scope
25 getPackageIncludePath,
27 getPackageLibraryPath,
29 getPackageExtraCcOpts,
30 getPackageFrameworkPath,
32 getExplicitPackagesAnd,
39 #include "HsVersions.h"
42 import SysTools ( getTopDir, getPackageConfigPath )
43 import ParsePkgConf ( loadPackageConfig )
44 import DynFlags ( dopt, DynFlag(..), DynFlags(..), PackageFlag(..) )
45 import StaticFlags ( opt_Static )
46 import Config ( cProjectVersion )
47 import Name ( Name, nameModule_maybe )
53 import Maybes ( expectJust, MaybeErr(..) )
57 #if __GLASGOW_HASKELL__ >= 603
58 import System.Directory ( getAppUserDataDirectory )
60 import Compat.Directory ( getAppUserDataDirectory )
63 import Distribution.InstalledPackageInfo
64 import Distribution.Package
65 import Distribution.Version
66 import Data.Maybe ( isNothing )
67 import System.Directory ( doesFileExist )
68 import Control.Monad ( foldM )
69 import Data.List ( nub, partition, sortBy )
71 #ifdef mingw32_TARGET_OS
72 import Data.List ( isPrefixOf )
76 import EXCEPTION ( throwDyn )
77 import ErrUtils ( debugTraceMsg, putMsg, Message )
79 -- ---------------------------------------------------------------------------
82 -- Package state is all stored in DynFlags, including the details of
83 -- all packages, which packages are exposed, and which modules they
86 -- The package state is computed by initPackages, and kept in DynFlags.
88 -- * -package <pkg> causes <pkg> to become exposed, and all other packages
89 -- with the same name to become hidden.
91 -- * -hide-package <pkg> causes <pkg> to become hidden.
93 -- * Let exposedPackages be the set of packages thus exposed.
94 -- Let depExposedPackages be the transitive closure from exposedPackages of
95 -- their dependencies.
97 -- * It is an error for any two packages in depExposedPackages to provide the
100 -- * When searching for a module from an explicit import declaration,
101 -- only the exposed modules in exposedPackages are valid.
103 -- * When searching for a module from an implicit import, all modules
104 -- from depExposedPackages are valid.
106 -- * When linking in a comp manager mode, we link in packages the
107 -- program depends on (the compiler knows this list by the
108 -- time it gets to the link step). Also, we link in all packages
109 -- which were mentioned with explicit -package flags on the command-line,
110 -- or are a transitive dependency of same, or are "base"/"rts".
111 -- The reason for (b) is that we might need packages which don't
112 -- contain any Haskell modules, and therefore won't be discovered
113 -- by the normal mechanism of dependency tracking.
116 -- One important thing that the package state provides is a way to
117 -- tell, for a given module, whether it is part of the current package
118 -- or not. We need to know this for two reasons:
120 -- * generating cross-DLL calls is different from intra-DLL calls
122 -- * we don't record version information in interface files for entities
123 -- in a different package.
127 -- When compiling module A, which imports module B, we need to
128 -- know whether B will be in the same DLL as A.
129 -- If it's in the same DLL, we refer to B_f_closure
130 -- If it isn't, we refer to _imp__B_f_closure
131 -- When compiling A, we record in B's Module value whether it's
132 -- in a different DLL, by setting the DLL flag.
134 data PackageState = PackageState {
136 explicitPackages :: [PackageId],
137 -- The packages we're going to link in eagerly. This list
138 -- should be in reverse dependency order; that is, a package
139 -- is always mentioned before the packages it depends on.
141 origPkgIdMap :: PackageConfigMap, -- PackageId -> PackageConfig
142 -- the full package database
144 pkgIdMap :: PackageConfigMap, -- PackageId -> PackageConfig
145 -- Derived from origPkgIdMap.
146 -- The exposed flags are adjusted according to -package and
147 -- -hide-package flags, and -ignore-package removes packages.
149 moduleToPkgConfAll :: ModuleEnv [(PackageConfig,Bool)],
150 -- Derived from pkgIdMap.
151 -- Maps Module to (pkgconf,exposed), where pkgconf is the
152 -- PackageConfig for the package containing the module, and
153 -- exposed is True if the package exposes that module.
155 -- The PackageIds of some known packages
156 basePackageId :: PackageIdH,
157 rtsPackageId :: PackageIdH,
158 haskell98PackageId :: PackageIdH,
159 thPackageId :: PackageIdH
163 = HomePackage -- The "home" package is the package curently
165 | ExtPackage PackageId -- An "external" package is any other package
168 isHomePackage :: PackageIdH -> Bool
169 isHomePackage HomePackage = True
170 isHomePackage (ExtPackage _) = False
172 -- A PackageConfigMap maps a PackageId to a PackageConfig
173 type PackageConfigMap = UniqFM PackageConfig
175 emptyPackageConfigMap :: PackageConfigMap
176 emptyPackageConfigMap = emptyUFM
178 lookupPackage :: PackageConfigMap -> PackageId -> Maybe PackageConfig
179 lookupPackage = lookupUFM
181 extendPackageConfigMap
182 :: PackageConfigMap -> [PackageConfig] -> PackageConfigMap
183 extendPackageConfigMap pkg_map new_pkgs
184 = foldl add pkg_map new_pkgs
185 where add pkg_map p = addToUFM pkg_map (packageConfigId p) p
187 getPackageDetails :: PackageState -> PackageId -> PackageConfig
188 getPackageDetails dflags ps = expectJust "getPackageDetails" (lookupPackage (pkgIdMap dflags) ps)
190 -- ----------------------------------------------------------------------------
191 -- Loading the package config files and building up the package state
193 -- | Call this after parsing the DynFlags. It reads the package
194 -- configuration files, and sets up various internal tables of package
195 -- information, according to the package-related flags on the
196 -- command-line (@-package@, @-hide-package@ etc.)
197 initPackages :: DynFlags -> IO DynFlags
198 initPackages dflags = do
199 pkg_map <- readPackageConfigs dflags;
200 state <- mkPackageState dflags pkg_map
201 return dflags{ pkgState = state }
203 -- -----------------------------------------------------------------------------
204 -- Reading the package database(s)
206 readPackageConfigs :: DynFlags -> IO PackageConfigMap
207 readPackageConfigs dflags = do
208 -- System one always comes first
209 system_pkgconf <- getPackageConfigPath
210 pkg_map1 <- readPackageConfig dflags emptyPackageConfigMap system_pkgconf
212 -- Read user's package conf (eg. ~/.ghc/i386-linux-6.3/package.conf)
213 -- unless the -no-user-package-conf flag was given.
214 -- We only do this when getAppUserDataDirectory is available
216 (exists, pkgconf) <- catch (do
217 appdir <- getAppUserDataDirectory "ghc"
220 `joinFileName` (TARGET_ARCH ++ '-':TARGET_OS ++ '-':cProjectVersion)
221 `joinFileName` "package.conf"
222 flg <- doesFileExist pkgconf
223 return (flg, pkgconf))
224 -- gobble them all up and turn into False.
225 (\ _ -> return (False, ""))
226 pkg_map2 <- if (dopt Opt_ReadUserPackageConf dflags && exists)
227 then readPackageConfig dflags pkg_map1 pkgconf
230 -- Read all the ones mentioned in -package-conf flags
231 pkg_map <- foldM (readPackageConfig dflags) pkg_map2
232 (extraPkgConfs dflags)
238 :: DynFlags -> PackageConfigMap -> FilePath -> IO PackageConfigMap
239 readPackageConfig dflags pkg_map conf_file = do
240 debugTraceMsg dflags 2 ("Using package config file: " ++ conf_file)
241 proto_pkg_configs <- loadPackageConfig conf_file
243 let pkg_configs1 = mungePackagePaths top_dir proto_pkg_configs
244 pkg_configs2 = maybeHidePackages dflags pkg_configs1
245 return (extendPackageConfigMap pkg_map pkg_configs2)
247 maybeHidePackages :: DynFlags -> [PackageConfig] -> [PackageConfig]
248 maybeHidePackages dflags pkgs
249 | dopt Opt_HideAllPackages dflags = map hide pkgs
252 hide pkg = pkg{ exposed = False }
254 mungePackagePaths :: String -> [PackageConfig] -> [PackageConfig]
255 -- Replace the string "$topdir" at the beginning of a path
256 -- with the current topdir (obtained from the -B option).
257 mungePackagePaths top_dir ps = map munge_pkg ps
259 munge_pkg p = p{ importDirs = munge_paths (importDirs p),
260 includeDirs = munge_paths (includeDirs p),
261 libraryDirs = munge_paths (libraryDirs p),
262 frameworkDirs = munge_paths (frameworkDirs p) }
264 munge_paths = map munge_path
267 | Just p' <- maybePrefixMatch "$topdir" p = top_dir ++ p'
271 -- -----------------------------------------------------------------------------
272 -- When all the command-line options are in, we can process our package
273 -- settings and populate the package state.
275 mkPackageState :: DynFlags -> PackageConfigMap -> IO PackageState
276 mkPackageState dflags orig_pkg_db = do
278 -- Modify the package database according to the command-line flags
279 -- (-package, -hide-package, -ignore-package, -hide-all-packages).
281 -- Also, here we build up a set of the packages mentioned in -package
282 -- flags on the command line; these are called the "explicit" packages.
283 -- we link these packages in eagerly. The explicit set should contain
284 -- at least rts & base, which is why we pretend that the command line
285 -- contains -package rts & -package base.
288 flags = reverse (packageFlags dflags)
290 procflags pkgs expl [] = return (pkgs,expl)
291 procflags pkgs expl (ExposePackage str : flags) = do
292 case pick str pkgs of
293 Nothing -> missingPackageErr str
294 Just (p,ps) -> procflags (p':ps') expl' flags
295 where pkgid = packageConfigId p
296 p' = p {exposed=True}
297 ps' = hideAll (pkgName (package p)) ps
298 expl' = addOneToUniqSet expl pkgid
299 procflags pkgs expl (HidePackage str : flags) = do
300 case partition (matches str) pkgs of
301 ([],_) -> missingPackageErr str
302 (ps,qs) -> procflags (map hide ps ++ qs) expl flags
303 where hide p = p {exposed=False}
304 procflags pkgs expl (IgnorePackage str : flags) = do
305 case partition (matches str) pkgs of
306 (ps,qs) -> procflags qs expl flags
307 -- missing package is not an error for -ignore-package,
308 -- because a common usage is to -ignore-package P as
309 -- a preventative measure just in case P exists.
312 = case partition (matches str) pkgs of
315 case sortBy (flip (comparing (pkgVersion.package))) ps of
316 (p:ps) -> Just (p, ps ++ rest)
317 _ -> panic "Packages.pick"
319 comparing f a b = f a `compare` f b
321 -- A package named on the command line can either include the
322 -- version, or just the name if it is unambiguous.
324 = str == showPackageId (package p)
325 || str == pkgName (package p)
327 -- When a package is requested to be exposed, we hide all other
328 -- packages with the same name.
329 hideAll name ps = map maybe_hide ps
330 where maybe_hide p | pkgName (package p) == name = p {exposed=False}
333 (pkgs1,explicit) <- procflags (eltsUFM orig_pkg_db) emptyUniqSet flags
335 -- hide all packages for which there is also a later version
336 -- that is already exposed. This just makes it non-fatal to have two
337 -- versions of a package exposed, which can happen if you install a
338 -- later version of a package in the user database, for example.
341 pkgs2 = map maybe_hide pkgs1
343 | a_later_version_is_exposed = p {exposed=False}
345 where myname = pkgName (package p)
346 myversion = pkgVersion (package p)
347 a_later_version_is_exposed
348 = not (null [ p | p <- pkgs1, let pkg = package p,
349 pkgName pkg == myname,
350 pkgVersion pkg > myversion ])
352 -- Eliminate any packages which have dangling dependencies (perhaps
353 -- because the package was removed by -ignore-package).
356 elimDanglingDeps pkgs =
357 case partition (hasDanglingDeps pkgs) pkgs of
359 (ps,qs) -> elimDanglingDeps qs
361 hasDanglingDeps pkgs p = any dangling (depends p)
362 where dangling pid = pid `notElem` all_pids
363 all_pids = map package pkgs
365 let pkgs = elimDanglingDeps pkgs2
366 pkg_db = extendPackageConfigMap emptyPackageConfigMap pkgs
368 -- Find the transitive closure of dependencies of exposed
370 let exposed_pkgids = [ packageConfigId p | p <- pkgs, exposed p ]
371 dep_exposed <- closeDeps pkg_db exposed_pkgids
373 -- Look up some known PackageIds
376 lookupPackageByName :: FastString -> PackageIdH
377 lookupPackageByName nm =
378 case [ conf | p <- dep_exposed,
379 Just conf <- [lookupPackage pkg_db p],
380 nm == mkFastString (pkgName (package conf)) ] of
382 (p:ps) -> ExtPackage (mkPackageId (package p))
384 -- Get the PackageIds for some known packages (we know the names,
385 -- but we don't know the versions). Some of these packages might
386 -- not exist in the database, so they are Maybes.
387 basePackageId = lookupPackageByName basePackageName
388 rtsPackageId = lookupPackageByName rtsPackageName
389 haskell98PackageId = lookupPackageByName haskell98PackageName
390 thPackageId = lookupPackageByName thPackageName
392 -- add base & rts to the explicit packages
393 basicLinkedPackages = [basePackageId,rtsPackageId]
394 explicit' = addListToUniqSet explicit
395 [ p | ExtPackage p <- basicLinkedPackages ]
397 -- Close the explicit packages with their dependencies
399 dep_explicit <- closeDeps pkg_db (uniqSetToList explicit')
401 -- Build up a mapping from Module -> PackageConfig for all modules.
402 -- Discover any conflicts at the same time, and factor in the new exposed
403 -- status of each package.
405 let mod_map = mkModuleMap pkg_db dep_exposed
407 return PackageState{ explicitPackages = dep_explicit,
408 origPkgIdMap = orig_pkg_db,
410 moduleToPkgConfAll = mod_map,
411 basePackageId = basePackageId,
412 rtsPackageId = rtsPackageId,
413 haskell98PackageId = haskell98PackageId,
414 thPackageId = thPackageId
418 basePackageName = FSLIT("base")
419 rtsPackageName = FSLIT("rts")
420 haskell98PackageName = FSLIT("haskell98")
421 thPackageName = FSLIT("template-haskell")
422 -- Template Haskell libraries in here
427 -> ModuleEnv [(PackageConfig, Bool)]
428 mkModuleMap pkg_db pkgs = foldr extend_modmap emptyUFM pkgs
430 extend_modmap pkgname modmap =
431 addListToUFM_C (++) modmap
432 [(m, [(pkg, m `elem` exposed_mods)]) | m <- all_mods]
434 pkg = expectJust "mkModuleMap" (lookupPackage pkg_db pkgname)
435 exposed_mods = map mkModule (exposedModules pkg)
436 hidden_mods = map mkModule (hiddenModules pkg)
437 all_mods = exposed_mods ++ hidden_mods
439 -- -----------------------------------------------------------------------------
440 -- Check for conflicts in the program.
442 -- | A conflict arises if the program contains two modules with the same
443 -- name, which can arise if the program depends on multiple packages that
444 -- expose the same module, or if the program depends on a package that
445 -- contains a module also present in the program (the "home package").
447 checkForPackageConflicts
449 -> [Module] -- modules in the home package
450 -> [PackageId] -- packages on which the program depends
451 -> MaybeErr Message ()
453 checkForPackageConflicts dflags mods pkgs = do
455 state = pkgState dflags
456 pkg_db = pkgIdMap state
458 dep_pkgs <- closeDepsErr pkg_db pkgs
461 extend_modmap pkgname modmap =
462 addListToFM_C (++) modmap
463 [(m, [(pkg, m `elem` exposed_mods)]) | m <- all_mods]
465 pkg = expectJust "checkForPackageConflicts"
466 (lookupPackage pkg_db pkgname)
467 exposed_mods = map mkModule (exposedModules pkg)
468 hidden_mods = map mkModule (hiddenModules pkg)
469 all_mods = exposed_mods ++ hidden_mods
471 mod_map = foldr extend_modmap emptyFM pkgs
472 mod_map_list :: [(Module,[(PackageConfig,Bool)])]
473 mod_map_list = fmToList mod_map
475 overlaps = [ (m, map fst ps) | (m,ps@(_:_:_)) <- mod_map_list ]
477 if not (null overlaps)
478 then Failed (pkgOverlapError overlaps)
482 overlap_mods = [ (mod,pkg)
484 Just ((pkg,_):_) <- [lookupFM mod_map mod] ]
485 -- will be only one package here
486 if not (null overlap_mods)
487 then Failed (modOverlapError overlap_mods)
492 pkgOverlapError overlaps = vcat (map msg overlaps)
495 text "conflict: module" <+> quotes (ppr mod)
496 <+> ptext SLIT("is present in multiple packages:")
497 <+> hsep (punctuate comma (map (text.showPackageId.package) pkgs))
499 modOverlapError overlaps = vcat (map msg overlaps)
501 msg (mod,pkg) = fsep [
502 text "conflict: module",
504 ptext SLIT("belongs to the current program/library"),
505 ptext SLIT("and also to package"),
506 text (showPackageId (package pkg)) ]
508 -- -----------------------------------------------------------------------------
509 -- Extracting information from the packages in scope
511 -- Many of these functions take a list of packages: in those cases,
512 -- the list is expected to contain the "dependent packages",
513 -- i.e. those packages that were found to be depended on by the
514 -- current module/program. These can be auto or non-auto packages, it
515 -- doesn't really matter. The list is always combined with the list
516 -- of explicit (command-line) packages to determine which packages to
519 getPackageIncludePath :: DynFlags -> [PackageId] -> IO [String]
520 getPackageIncludePath dflags pkgs = do
521 ps <- getExplicitPackagesAnd dflags pkgs
522 return (nub (filter notNull (concatMap includeDirs ps)))
524 -- includes are in reverse dependency order (i.e. rts first)
525 getPackageCIncludes :: [PackageConfig] -> IO [String]
526 getPackageCIncludes pkg_configs = do
527 return (reverse (nub (filter notNull (concatMap includes pkg_configs))))
529 getPackageLibraryPath :: DynFlags -> [PackageId] -> IO [String]
530 getPackageLibraryPath dflags pkgs = do
531 ps <- getExplicitPackagesAnd dflags pkgs
532 return (nub (filter notNull (concatMap libraryDirs ps)))
534 getPackageLinkOpts :: DynFlags -> [PackageId] -> IO [String]
535 getPackageLinkOpts dflags pkgs = do
536 ps <- getExplicitPackagesAnd dflags pkgs
537 let tag = buildTag dflags
538 rts_tag = rtsBuildTag dflags
540 imp = if opt_Static then "" else "_dyn"
541 libs p = map ((++imp) . addSuffix) (hACK (hsLibraries p)) ++ extraLibraries p
542 all_opts p = map ("-l" ++) (libs p) ++ ldOptions p
544 suffix = if null tag then "" else '_':tag
545 rts_suffix = if null rts_tag then "" else '_':rts_tag
547 addSuffix rts@"HSrts" = rts ++ rts_suffix
548 addSuffix other_lib = other_lib ++ suffix
550 return (concat (map all_opts ps))
553 -- This is a totally horrible (temporary) hack, for Win32. Problem is
554 -- that package.conf for Win32 says that the main prelude lib is
555 -- split into HSbase1, HSbase2 and HSbase3, which is needed due to a bug
556 -- in the GNU linker (PEi386 backend). However, we still only
557 -- have HSbase.a for static linking, not HSbase{1,2,3}.a
558 -- getPackageLibraries is called to find the .a's to add to the static
559 -- link line. On Win32, this hACK detects HSbase{1,2,3} and
560 -- replaces them with HSbase, so static linking still works.
561 -- Libraries needed for dynamic (GHCi) linking are discovered via
562 -- different route (in InteractiveUI.linkPackage).
563 -- See driver/PackageSrc.hs for the HSbase1/HSbase2 split definition.
564 -- THIS IS A STRICTLY TEMPORARY HACK (famous last words ...)
565 -- JRS 04 Sept 01: Same appalling hack for HSwin32[1,2]
566 -- KAA 29 Mar 02: Same appalling hack for HSobjectio[1,2,3,4]
568 -- [sof 03/05: Renamed the (moribund) HSwin32 to HSwin_32 so as to
569 -- avoid filename conflicts with the 'Win32' package on a case-insensitive filesystem]
571 # if !defined(mingw32_TARGET_OS) && !defined(cygwin32_TARGET_OS)
574 = if "HSbase1" `elem` libs && "HSbase2" `elem` libs && "HSbase3" `elem` libs
575 then "HSbase" : filter (not.(isPrefixOf "HSbase")) libs
577 if "HSwin_321" `elem` libs && "HSwin_322" `elem` libs
578 then "HSwin_32" : filter (not.(isPrefixOf "HSwin_32")) libs
580 if "HSobjectio1" `elem` libs && "HSobjectio2" `elem` libs && "HSobjectio3" `elem` libs && "HSobjectio4" `elem` libs
581 then "HSobjectio" : filter (not.(isPrefixOf "HSobjectio")) libs
586 getPackageExtraCcOpts :: DynFlags -> [PackageId] -> IO [String]
587 getPackageExtraCcOpts dflags pkgs = do
588 ps <- getExplicitPackagesAnd dflags pkgs
589 return (concatMap ccOptions ps)
591 getPackageFrameworkPath :: DynFlags -> [PackageId] -> IO [String]
592 getPackageFrameworkPath dflags pkgs = do
593 ps <- getExplicitPackagesAnd dflags pkgs
594 return (nub (filter notNull (concatMap frameworkDirs ps)))
596 getPackageFrameworks :: DynFlags -> [PackageId] -> IO [String]
597 getPackageFrameworks dflags pkgs = do
598 ps <- getExplicitPackagesAnd dflags pkgs
599 return (concatMap frameworks ps)
601 -- -----------------------------------------------------------------------------
604 -- | Takes a Module, and if the module is in a package returns
605 -- @(pkgconf,exposed)@ where pkgconf is the PackageConfig for that package,
606 -- and exposed is True if the package exposes the module.
607 lookupModuleInAllPackages :: DynFlags -> Module -> [(PackageConfig,Bool)]
608 lookupModuleInAllPackages dflags m =
609 case lookupModuleEnv (moduleToPkgConfAll (pkgState dflags)) m of
613 getExplicitPackagesAnd :: DynFlags -> [PackageId] -> IO [PackageConfig]
614 getExplicitPackagesAnd dflags pkgids =
616 state = pkgState dflags
617 pkg_map = pkgIdMap state
618 expl = explicitPackages state
620 all_pkgs <- throwErr (foldM (add_package pkg_map) expl pkgids)
621 return (map (getPackageDetails state) all_pkgs)
623 -- Takes a list of packages, and returns the list with dependencies included,
624 -- in reverse dependency order (a package appears before those it depends on).
625 closeDeps :: PackageConfigMap -> [PackageId] -> IO [PackageId]
626 closeDeps pkg_map ps = throwErr (closeDepsErr pkg_map ps)
628 throwErr :: MaybeErr Message a -> IO a
629 throwErr m = case m of
630 Failed e -> throwDyn (CmdLineError (showSDoc e))
631 Succeeded r -> return r
633 closeDepsErr :: PackageConfigMap -> [PackageId]
634 -> MaybeErr Message [PackageId]
635 closeDepsErr pkg_map ps = foldM (add_package pkg_map) [] ps
638 add_package :: PackageConfigMap -> [PackageId] -> PackageId
639 -> MaybeErr Message [PackageId]
640 add_package pkg_db ps p
641 | p `elem` ps = return ps -- Check if we've already added this package
643 case lookupPackage pkg_db p of
644 Nothing -> Failed (missingPackageErr (packageIdString p))
646 -- Add the package's dependents also
647 let deps = map mkPackageId (depends pkg)
648 ps' <- foldM (add_package pkg_db) ps deps
651 missingPackageErr p = throwDyn (CmdLineError (showSDoc (missingPackageMsg p)))
652 missingPackageMsg p = ptext SLIT("unknown package:") <> text p
654 -- -----------------------------------------------------------------------------
655 -- The home module set
657 newtype HomeModules = HomeModules ModuleSet
659 mkHomeModules :: [Module] -> HomeModules
660 mkHomeModules = HomeModules . mkModuleSet
662 isHomeModule :: HomeModules -> Module -> Bool
663 isHomeModule (HomeModules set) mod = elemModuleSet mod set
665 -- Determining whether a Name refers to something in another package or not.
666 -- Cross-package references need to be handled differently when dynamically-
667 -- linked libraries are involved.
669 isDllName :: HomeModules -> Name -> Bool
672 | Just mod <- nameModule_maybe name = not (isHomeModule pdeps mod)
673 | otherwise = False -- no, it is not even an external name
675 -- -----------------------------------------------------------------------------
676 -- Displaying packages
678 dumpPackages :: DynFlags -> IO ()
679 -- Show package info on console, if verbosity is >= 3
681 = do let pkg_map = pkgIdMap (pkgState dflags)
683 vcat (map (text.showInstalledPackageInfo) (eltsUFM pkg_map))