multiple cabal files in one directory?

Peter Simons simons at
Mon Jan 10 11:23:16 CET 2011

Hi Kathleen,

 > Is it possible to have a directory with multiple cabal files, telling
 > cabal which file to use for a given install request by passing in a
 > flag, say something like:
 >   cabal install -f pads.cabal
 > or
 >   cabal install -f forest.cabal
 > In other words, something like the -f option in make.

I would like to have that feature in cabal, too, and at first glance it looks
like a trivial thing to support. Unfortunately, it is not that easy. When we
think of build instructions for Cabal, we tend to think of the "pkgname.cabal"
file, but in fact that file is only half of it. The other half is "Setup.hs".
Now, the vast majority of Haskell packages doesn't use Setup.hs, because
building those packages is simple and the default settings hard-coded into
Cabal get the job done just fine. There are packages, however, that ship custom
written Setup.hs files that contains plenty of complex build know-how.

So, instead of saying "cabal install -f pads.cabal", we would really have to
say "cabal install -f1 pads.cabal -f2 Setup-pads.hs" or something like that. We
*could* do that, of course, but obviously the makers of Cabal felt that it's
easier to expect that separate packages live in separate directories, so that
Setup.hs can be called "Setup.hs" in every package.

Arguably, the choice to include the package name in the name of the Cabal file
is inconsistent with that decision, and that inconsistency is confusing. If you
look at a random package, then "foo.cabal" feels like a file that's specific to
this package, but "Setup.hs" feels like a file that is generic. In fact, both
are specific to this package, even though the name of the latter file doesn't
make that clear.

Take care,

More information about the Libraries mailing list