- --
- -- Eliminate any packages which have dangling dependencies (perhaps
- -- because the package was removed by -ignore-package).
- --
- let
- elimDanglingDeps pkgs =
- case partition (not.null.snd) (map (getDanglingDeps pkgs) pkgs) of
- ([],ps) -> return (map fst ps)
- (ps,qs) -> do
- mapM_ reportElim ps
- elimDanglingDeps (map fst qs)
-
- reportElim (p, deps) =
- debugTraceMsg dflags 2 $
- (ptext SLIT("package") <+> pprPkg p <+>
- ptext SLIT("will be ignored due to missing dependencies:") $$
- nest 2 (hsep (map (text.showPackageId) deps)))
+ return (pkgs2, preload1, new_this_pkg)
+
+-- -----------------------------------------------------------------------------
+--
+-- Eliminate any packages which have dangling dependencies (
+-- because the dependency was removed by -ignore-package).
+--
+elimDanglingDeps
+ :: DynFlags
+ -> [PackageConfig]
+ -> [PackageId] -- ignored packages
+ -> IO [PackageConfig]
+
+elimDanglingDeps dflags pkgs ignored =
+ case partition (not.null.snd) (map (getDanglingDeps pkgs ignored) pkgs) of
+ ([],ps) -> return (map fst ps)
+ (ps,qs) -> do
+ mapM_ reportElim ps
+ elimDanglingDeps dflags (map fst qs)
+ (ignored ++ map packageConfigId (map fst ps))
+ where
+ reportElim (p, deps) =
+ debugTraceMsg dflags 2 $
+ (ptext SLIT("package") <+> pprPkg p <+>
+ ptext SLIT("will be ignored due to missing dependencies:") $$
+ nest 2 (hsep (map (text.showPackageId) deps)))
+
+ getDanglingDeps pkgs ignored p = (p, filter dangling (depends p))
+ where dangling pid = mkPackageId pid `elem` ignored
+
+-- -----------------------------------------------------------------------------
+-- When all the command-line options are in, we can process our package
+-- settings and populate the package state.
+
+mkPackageState
+ :: DynFlags
+ -> PackageConfigMap -- initial database
+ -> [PackageId] -- preloaded packages
+ -> PackageId -- this package
+ -> IO (PackageState,
+ [PackageId], -- new packages to preload
+ PackageId) -- this package, might be modified if the current