[Haskell-cafe] is there a way to patch the build-depends line of a cabal file without breaking backwards compatibility?

Thomas Schilling nominolo at googlemail.com
Mon Aug 20 20:26:04 EDT 2007


On 20 aug 2007, at 20.58, Thomas Hartman wrote:

>
> > Take a look at the Cabal.cabal file, how this is solved, atm.
>
> where is this, how can I take a look at it?

http://darcs.haskell.org/cabal/Cabal.cabal

See below for a little more explaination.

>
> > The next release of Cabal (and the current HEAD) supports   
> conditionals
>
> I couldn't install head, but since I'm running 6.7, do I already  
> have it?
>

Yes, you already have it.  It should be in ghc/libraries/Cabal, or  
contrib/Cabal

> hartthoma at linuxpt:~/installs/cabal-head/cabal>runghc Setup.lhs  
> configure
>
> Distribution/Simple/InstallDirs.hs:267:36:
>     Not in scope: `dropDrive'
>
> hartthoma at linuxpt:~/installs/cabal-head/cabal>ls -l `which ghc`
> lrwxrwxrwx 1 root root 31 2007-08-20 11:08 /usr/local/bin/ghc -> / 
> usr/local/bin/ghc-6.7.20070816
>

See Neil's reply.

>
> hartthoma at linuxpt:~/installs/cabal-head/cabal>ghc-pkg list | grep - 
> i cabal
>     Cabal-1.1.7
>
> >  Please also note that this might not be the
> > best way to use the new features;  as I suggested in another thread,
> > simulating base-1.0 on systems with base-2.0 is probably best  
> handled
> > with a base.cabal file that imports base-2.0, old-time, etc. and re-
> > exports all imported modules to get a "virtual" base-1.0.
>
> I'm interested in seeing how this works, but I couldn't find that  
> other thread.
>

There is no formal proposal, yet, and I think the note was in a  
recent thread on cabal-devel or libraries.  Therefore, I won't  
discuss it here.  I can tell you the current solution, though.

> Where is the documentation for the new functionality in cabal head,  
> or do you just have to read the source code for now?
>
Performing (in the Cabal directory) "make doc" should build the  
haddocks and the latest user's guide.  Performing "make users-guide"  
should only build the user's guide, but since that requires some  
tools which might be non-trivial to set up on some systems, I didn't  
recommend it.

So here's the relevant part of how Cabal.cabal does it:

   if flag(small_base) {
     -- For ghc 6.2 you need to add 'unix' to Build-Depends:
     Build-Depends: base, filepath, pretty, directory, old-time,  
process, containers
   } else {
     Build-Depends: base, filepath
   }

Note, that the format changed to a sectioned format, and that it is  
quite likely that it will still change slightly before the release.   
Consult the Cabal user's guide or (probably easier) take a look at  
other .cabal files in the ghc tree.  It's quite straightforward,  
actually.

The interesting feature here is that unless overridden explicitly,  
the flag "small_base" will be assigned to a value appropriate for the  
system, thus, if you don't have any of the packages pretty,  
directory, etc, it will automatically be assigned to false. (I think  
it better should be base >= 2.0, though.)

(Also, the comment can now be replaced by an actual test like: if impl 
(ghc <=6.2) ..)

HTH
/ Thomas




More information about the Haskell-Cafe mailing list