48
votes

Given a set of cabal packages, is there a way to automatically calculate subset of independent packages? In other words, subset of packages that will be sufficient to install them all.

For [network,parsec] the answer is [network] because it network depends on parsec.

For [network,containers] the answer is [network,containers] because:

  • network does not depend on containers
  • all networks dependencies not depends on containers
  • containers does not depend on network
  • all containerss dependencies not depends on network

It's not hard to find the answer for 2 packages. What is really interesting is to find out independent set for [containers, directory, filepath, lens, xml, http-conduit, regex-posix, monad-control, unordered-containers, glib, hashable, hspec, split, aeson, attoparsec, stm, QuickCheck].


From answer I expect some function based on cabal library like ∷ [Packages] → IO [Packages].

1
Looks like Distribution.Client.PackageIndex.dependencyClosure is what you need.Mikhail Glushenkov
The Git version of cabal-install (Distribution.Client.*) is also a library now.Mikhail Glushenkov
cabal-sort --parallel will display independently buildable groups of packages (which isn't quite what you want, but related ;)Conrad Parker
There is no unique solution. All you could possibly do is to find one minimal subset whose transitive dependencies span the entire set. For example, you would basically just loop over all packages and iteratively add them to the minimal subset if not already contained in the set of transitive dependencies of the minimal subset.user1050755

1 Answers

1
votes

Cabal is moving to a more NPM-like model, which will make dependency resolution much simpler. Each installed package will keep a local copy of its dependencies, trading a little disk space for the headache of installing multiple global packages with mutually exclusive package versioning demands.

Under this model, the subset of packages required to install a set of packages == that set. Though one may be a dependency of the other, each installed copy will keep its own local copy of its dependencies, so Cabal won't consider the dependency installed that way any more.