[commit: Cabal] master: Refactor getBuildDeps and redefine flattenDepList in terms of it. (8f3cc66)

Ian Lynagh igloo at earth.li
Fri Jun 24 01:45:09 CEST 2011


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

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/8f3cc663be9ce7acdfc1107b3e95f9eca4804a3e

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

commit 8f3cc663be9ce7acdfc1107b3e95f9eca4804a3e
Author: bjorn <bjorn at bringert.net>
Date:   Thu Oct 4 17:50:47 2007 +0000

    Refactor getBuildDeps and redefine flattenDepList in terms of it.

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

 .../src/Network/Hackage/CabalInstall/Dependency.hs |   26 ++++++++-----------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
index 5b18d3b..64c7ca4 100644
--- a/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
+++ b/cabal-install/src/Network/Hackage/CabalInstall/Dependency.hs
@@ -49,24 +49,20 @@ flattenDepList :: [PackageIdentifier] -- ^List of installed packages.
                -> [ResolvedPackage]
 flattenDepList ps
     = nub . filter (not . isInstalled ps . fulfilling) . concatMap flatten
-    where flatten pkgInfo = subs ++ [pkgInfo]
-              where subs = case resolvedData pkgInfo of
-                             Just (_,_,subDeps) -> concatMap flatten subDeps
-                             Nothing            -> []
+    where flatten pkgInfo = getBuildDeps ps [pkgInfo] ++ [pkgInfo]
 
--- |Flattens a dependency list while only keeping the dependencies of the packages.
---  This is used for installing all the dependencies of a package but not the package itself.
+-- | Flattens a dependency list, keeping only the transitive closure of the 
+--   dependencies of the top-level packages.
+--   This is used for installing all the dependencies of set of packages but not the packages
+--   themselves. Filters out installed packages and duplicates.
 getBuildDeps :: [PackageIdentifier] -> [ResolvedPackage]
              -> [ResolvedPackage]
-getBuildDeps ps deps
-    = nub $ concatMap worker deps
-    where worker pkgInfo
-              = case getLatestPkg ps (fulfilling pkgInfo) of
-                  Just _pkg -> []
-                  Nothing -> case resolvedData pkgInfo of
-                               Just (_pkg,_location,subDeps)
-                                        -> flattenDepList ps subDeps
-                               Nothing -> []
+getBuildDeps ps
+    = nub . filter (not . isInstalled ps . fulfilling) . concatMap flattenDeps
+    where flattenDeps pkgInfo 
+              = case resolvedData pkgInfo of
+                  Just (_,_,subDeps) -> flattenDepList ps subDeps
+                  Nothing            -> []
 
 {-
 getReverseDeps :: [PackageIdentifier] -- All installed packages.





More information about the Cvs-libraries mailing list