Commit c4eae641 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Pull the planners out of install and pass them as parameters

parent 491c72d5
......@@ -91,13 +91,34 @@ install :: Verbosity
-> InstallFlags
-> [UnresolvedDependency]
-> IO ()
install verbosity packageDB repos comp conf configFlags installFlags deps = do
install verbosity packageDB repos comp conf configFlags installFlags deps =
installWithPlanner planner
verbosity packageDB repos comp conf configFlags installFlags
where
planner :: Planner
planner | null deps = planLocalPackage verbosity comp configFlags
| otherwise = planRepoPackages comp deps
type Planner = Maybe (PackageIndex InstalledPackageInfo)
-> PackageIndex AvailablePackage
-> IO (Either [Dependency] (InstallPlan BuildResult))
-- |Installs the packages generated by a planner.
installWithPlanner ::
Planner
-> Verbosity
-> PackageDB
-> [Repo]
-> Compiler
-> ProgramConfiguration
-> Cabal.ConfigFlags
-> InstallFlags
-> IO ()
installWithPlanner planner verbosity packageDB repos comp conf configFlags installFlags = do
installed <- getInstalledPackages verbosity comp packageDB conf
available <- fmap mconcat (mapM (IndexUtils.readRepoIndex verbosity) repos)
maybePlan <- if null deps
then planLocalPackage verbosity comp configFlags installed available
else planRepoPackages verbosity comp installed available deps
maybePlan <- planner installed available
info verbosity "Resolving dependencies..."
case maybePlan of
......@@ -163,13 +184,12 @@ planLocalPackage verbosity comp configFlags installed available = do
-- | Make an 'InstallPlan' for the given dependencies.
--
planRepoPackages :: Verbosity
-> Compiler
planRepoPackages :: Compiler
-> [UnresolvedDependency]
-> Maybe (PackageIndex InstalledPackageInfo)
-> PackageIndex AvailablePackage
-> [UnresolvedDependency]
-> IO (Either [Dependency] (InstallPlan BuildResult))
planRepoPackages _verbosity comp installed available deps = do
planRepoPackages comp deps installed available = do
deps' <- IndexUtils.disambiguateDependencies available deps
return $ resolveDependencies buildOS buildArch (compilerId comp)
installed available deps'
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment