Dependency guessing for cabal init

Brent Yorgey byorgey at
Fri Oct 21 22:29:28 CEST 2011

Hi everyone,

I'm working on some improvements to 'cabal init', the biggest of which
is looking at imports in source files to guess an initial list of
dependencies to populate the 'Build-depends:' field.  I wanted to get
some feedback on a design decision: what to do when we find multiple
packages providing the same module?

Suppose we find a source file with the line

  import Foo.Bar

So we get the list of installed packages, and look for packages
providing the Foo.Bar module.  If there's only one, great! We just
use that version of that package as a dependency (with a conservative
upper bound guided by the PVP).  However, I suspect that much of the
time we will instead find something like this:

Scenario A:


Scenario B:


all providing Foo.Bar.

In Scenario A, which do we pick as our dependency:

  (a) foobar >= 0.3 && < 0.5
  (b) foobar >= 0.4 && < 0.5
  (c) foobar >= 0.4.1 && < 0.5

Personally, I lean towards (b): the earliest version PVP-compatible
with the latest available version.  But I could in principle be
convinced of any of these options.

In Scenario B, do we:

  (a) arbitrarily pick a package (and generate a warning)
  (b) refuse to pick either package (and generate a warning)?
  (c) pick *both* and let the user clean up the mess later (and
      generate a warning)?

I suppose (b) seems most sensible.

It's possible no one really cares and it doesn't matter that much,
which is also fine. =)


More information about the cabal-devel mailing list