[commit: Cabal] master: Add lookupConfiguredPackage helper function to InstallPlan (0702b8e)
Ian Lynagh
igloo at earth.li
Fri Jun 24 01:53:24 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/0702b8e8578ba5f9485ec13ce293a4340eb4be55
>---------------------------------------------------------------
commit 0702b8e8578ba5f9485ec13ce293a4340eb4be55
Author: Duncan Coutts <duncan at haskell.org>
Date: Wed May 7 00:10:06 2008 +0000
Add lookupConfiguredPackage helper function to InstallPlan
Simplifies implementation of completed and failed
>---------------------------------------------------------------
cabal-install/Hackage/InstallPlan.hs | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/cabal-install/Hackage/InstallPlan.hs b/cabal-install/Hackage/InstallPlan.hs
index e715fed..0f883c0 100644
--- a/cabal-install/Hackage/InstallPlan.hs
+++ b/cabal-install/Hackage/InstallPlan.hs
@@ -232,10 +232,9 @@ next plan@(InstallPlan { planIndex = index }) = assert (invariant plan) $
completed :: PackageIdentifier
-> InstallPlan buildResult -> InstallPlan buildResult
completed pkgid plan =
- case PackageIndex.lookupPackageId index pkgid of
- Just (Configured cp) -> plan { planIndex = PackageIndex.insert (Installed cp) index }
- _ -> error "InstallPlan.completed: internal error; cannot mark package as completed"
- where index = planIndex plan
+ plan { planIndex = PackageIndex.insert installed (planIndex plan) }
+ where
+ installed = Installed (lookupConfiguredPackage plan pkgid)
-- | Marks a package in the graph as having failed. It also marks all the
-- packages that depended on it as having failed.
@@ -268,6 +267,16 @@ failed pkgid buildResult dependentBuildResult
in foldr markDepsAsFailed index'' deps
_ -> index'
+-- | lookup a package that we expect to be in the configured state
+--
+lookupConfiguredPackage :: InstallPlan a
+ -> PackageIdentifier -> ConfiguredPackage
+lookupConfiguredPackage plan pkgid =
+ case PackageIndex.lookupPackageId (planIndex plan) pkgid of
+ Just (Configured pkg) -> pkg
+ Just _ -> error $ "InstallPlan: not configured " ++ display pkgid
+ Nothing -> error $ "InstallPlan: no such package " ++ display pkgid
+
-- ------------------------------------------------------------
-- * Checking valididy of plans
-- ------------------------------------------------------------
More information about the Cvs-libraries
mailing list