[commit: Cabal] master: Refactoring: change getLatestPkg to work on PkgInfo, and use it in getDependency. (0762e16)
Ian Lynagh
igloo at earth.li
Fri Jun 24 01:45:11 CEST 2011
Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal
On branch : master
http://hackage.haskell.org/trac/ghc/changeset/0762e16512beaa6a85b70d30519bbacf2566cd62
>---------------------------------------------------------------
commit 0762e16512beaa6a85b70d30519bbacf2566cd62
Author: bjorn <bjorn at bringert.net>
Date: Thu Oct 4 18:09:50 2007 +0000
Refactoring: change getLatestPkg to work on PkgInfo, and use it in getDependency.
>---------------------------------------------------------------
.../src/Network/Hackage/CabalInstall/Dependency.hs | 24 +++++++------------
1 files changed, 9 insertions(+), 15 deletions(-)
diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
index 64c7ca4..8e77db7 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
@@ -111,15 +111,14 @@ resolvedDepToResolvedPkg (dep,rDep)
, map resolvedDepToResolvedPkg subDeps )
--- |Locates a @PackageIdentifier@ which satisfies a given @Dependency at .
+-- |Locates a @PkgInfo@ which satisfies a given @Dependency at .
-- Fails with "cannot satisfy dependency: %s." where %s == the given dependency.
-getLatestPkg :: (Monad m) => [PackageIdentifier] -> Dependency -> m PackageIdentifier
+getLatestPkg :: (Monad m) => [PkgInfo] -> Dependency -> m PkgInfo
getLatestPkg ps dep
- = case filter (fulfillDependency dep) ps of
+ = case filter (fulfillDependency dep . infoId) ps of
[] -> fail $ printf "cannot satisfy dependency: %s." (show (showDependency dep))
- qs -> let pkg = maximumBy versions qs
- versions a b = pkgVersion a `compare` pkgVersion b
- in return pkg
+ qs -> return $ maximumBy compareVersions qs
+ where compareVersions a b = pkgVersion (infoId a) `compare` pkgVersion (infoId b)
-- |Evaluates to @True@ if the given @Dependency@ is satisfied by the given @PackageIdentifer at .
fulfillDependency :: Dependency -> PackageIdentifier -> Bool
@@ -137,16 +136,11 @@ getDependency :: [PkgInfo]
-> UnresolvedDependency -> ResolvedPackage
getDependency ps (UnresolvedDependency { dependency=dep, depOptions=opts})
= ResolvedPackage { fulfilling = dep
- , resolvedData = d
+ , resolvedData = fmap pkgData (getLatestPkg ps dep)
, pkgOptions = opts }
- where d = case filter (fulfillDependency dep . infoId) ps of
- [] -> Nothing
- qs -> let p = maximumBy compareVersions qs
- in Just (infoId p
- , infoURL p
- , map (getDependency ps . depToUnresolvedDep) (infoDeps p))
- compareVersions a b = pkgVersion (infoId a) `compare` pkgVersion (infoId b)
-
+ where pkgData p = (infoId p
+ , infoURL p
+ , map (getDependency ps . depToUnresolvedDep) (infoDeps p))
-- |Get the PackageIdentifier, build options and location from a list of resolved packages.
-- Throws an exception if a package couldn't be resolved.
More information about the Cvs-libraries
mailing list