Commit 080b210d authored by bjorn@bringert.net's avatar bjorn@bringert.net
Browse files

Make resolveDependenciesAux pure.

parent 7e5135df
......@@ -12,7 +12,7 @@
-----------------------------------------------------------------------------
module Network.Hackage.CabalInstall.BuildDep where
import Network.Hackage.CabalInstall.Config (findCompiler)
import Network.Hackage.CabalInstall.Config (findCompiler, getKnownPackages)
import Network.Hackage.CabalInstall.Dependency (getPackages, getBuildDeps
, listInstalledPackages
, depToUnresolvedDep, resolveDependenciesAux)
......@@ -30,8 +30,9 @@ buildDep :: ConfigFlags -> [String] -> [UnresolvedDependency] -> IO ()
buildDep cfg globalArgs deps
= do (comp,conf) <- findCompiler cfg
ipkgs <- listInstalledPackages cfg comp conf
apkgs <- fmap getPackages (fmap (getBuildDeps ipkgs)
(resolveDependenciesAux cfg comp conf ipkgs deps))
available <- getKnownPackages cfg
let apkgs = getPackages $ getBuildDeps ipkgs $
resolveDependenciesAux cfg comp conf ipkgs available deps
installPackages cfg comp globalArgs apkgs
-- | Takes the path to a .cabal file, and installs the build-dependencies listed there.
......
......@@ -174,16 +174,17 @@ resolveDependenciesAux :: ConfigFlags
-> Compiler
-> ProgramConfiguration
-> [PackageIdentifier] -- ^Installed packages.
-> [PkgInfo] -- ^ Installable packages
-> [UnresolvedDependency] -- ^Dependencies in need of resolution.
-> IO [ResolvedPackage]
resolveDependenciesAux cfg comp conf installed deps
= do knownPkgs <- getKnownPackages cfg
let resolve dep
= let rDep = getDependency comp installed knownPkgs dep
-> [ResolvedPackage]
resolveDependenciesAux cfg comp conf installed available deps
= map resolve (filter (not . isInstalled installed . dependency) deps)
where resolve dep
= let rDep = getDependency comp installed available dep
in case resolvedData rDep of
Nothing -> resolvedDepToResolvedPkg (dependency dep,Nothing)
_ -> rDep
return $ map resolve (filter (not . isInstalled installed . dependency) deps)
-- |Resolve some dependencies from the known packages while filtering out installed packages.
-- The result has been modified to put the dependencies in front of the packages.
......@@ -194,7 +195,8 @@ resolveDependencies :: ConfigFlags
-> IO [ResolvedPackage]
resolveDependencies cfg comp conf deps
= do installed <- listInstalledPackages cfg comp conf
fmap (flattenDepList installed) (resolveDependenciesAux cfg comp conf installed deps)
available <- getKnownPackages cfg
return $ flattenDepList installed $ resolveDependenciesAux cfg comp conf installed available deps
listInstalledPackages :: ConfigFlags -> Compiler -> ProgramConfiguration -> IO [PackageIdentifier]
listInstalledPackages cfg comp conf =
......
Markdown is supported
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