Commit 150c3189 authored by Duncan Coutts's avatar Duncan Coutts
Browse files

Split out reusable lookupReadyPackage util in InstallPlan

Used in the next patch.
parent 2d065c8c
......@@ -77,7 +77,7 @@ import Distribution.Text
import Data.List
( foldl', intercalate )
import Data.Maybe
( fromMaybe, maybeToList )
( fromMaybe, catMaybes )
import qualified Data.Graph as Graph
import Data.Graph (Graph)
import qualified Data.Tree as Tree
......@@ -85,7 +85,6 @@ import Distribution.Compat.Binary (Binary(..))
import GHC.Generics
import Control.Exception
( assert )
import Data.Maybe (catMaybes)
import qualified Data.Map as Map
import qualified Data.Traversable as T
......@@ -357,12 +356,17 @@ ready plan = assert check readyPackages
processingPackages = [ pkg | Processing pkg <- toList plan]
readyPackages :: [GenericReadyPackage srcpkg ipkg]
readyPackages =
[ ReadyPackage srcpkg deps
| srcpkg <- configuredPackages
-- select only the package that have all of their deps installed:
, deps <- maybeToList (hasAllInstalledDeps srcpkg)
]
readyPackages = catMaybes (map (lookupReadyPackage plan) configuredPackages)
lookupReadyPackage :: forall ipkg srcpkg iresult ifailure.
PackageFixedDeps srcpkg
=> GenericInstallPlan ipkg srcpkg iresult ifailure
-> srcpkg
-> Maybe (GenericReadyPackage srcpkg ipkg)
lookupReadyPackage plan pkg = do
deps <- hasAllInstalledDeps pkg
return (ReadyPackage pkg deps)
where
hasAllInstalledDeps :: srcpkg -> Maybe (ComponentDeps [ipkg])
hasAllInstalledDeps = T.mapM (mapM isInstalledDep) . depends
......
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