Repository : ssh://darcs.haskell.org//srv/darcs/packages/Cabal

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/28813aca2a2c8ce359dd6db758a651c8d89298e9

>---------------------------------------------------------------

commit 28813aca2a2c8ce359dd6db758a651c8d89298e9
Author: bjorn <[email protected]>
Date:   Thu Oct 4 14:05:21 2007 +0000

    Refactor getDependency to make it easier to understand.

>---------------------------------------------------------------

 .../src/Network/Hackage/CabalInstall/Dependency.hs |   28 ++++++++-----------
 1 files changed, 12 insertions(+), 16 deletions(-)

diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs 
b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
index 184beb2..77d3339 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
@@ -137,22 +137,18 @@ fulfillDependency (Dependency depName vrange) pkg
 
 getDependency :: [PkgInfo]
               -> UnresolvedDependency -> ResolvedPackage
-getDependency ps (UnresolvedDependency { dependency=dep@(Dependency pkgname 
vrange)
-                                       , depOptions=opts})
-    = case filter ok ps of
-        [] -> ResolvedPackage
-              { fulfilling = dep
-              , resolvedData = Nothing
-              , pkgOptions = opts }
-        qs -> let PkgInfo { infoId = pkg, infoDeps = deps, infoURL = location 
} = maximumBy versions qs
-                  versions a b = pkgVersion (infoId a) `compare` pkgVersion 
(infoId b)
-              in ResolvedPackage
-                 { fulfilling = dep
-                 , resolvedData = Just ( pkg
-                                       , location
-                                       , (map (getDependency ps) (map 
depToUnresolvedDep deps)))
-                 , pkgOptions = opts }
-    where ok PkgInfo{ infoId = p } = pkgName p == pkgname && pkgVersion p 
`withinRange` vrange
+getDependency ps (UnresolvedDependency { dependency=dep, depOptions=opts})
+    = ResolvedPackage { fulfilling = dep
+                      , resolvedData = d
+                      , 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)
+
 
 -- |Get the PackageIdentifier, build options and location from a list of 
resolved packages.
 --  Throws an exception if a package couldn't be resolved.



_______________________________________________
Cvs-libraries mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-libraries

Reply via email to