suggestion for a small extension to configurations

Ross Paterson ross at soi.city.ac.uk
Mon Nov 5 07:17:35 EST 2007


On Tue, Oct 16, 2007 at 11:15:14PM +0100, Duncan Coutts wrote:
> Here's my suggestion:
> 
> library
>   build-depends: base
>   if package(base >= 3)
>     build-depends: pretty, directory, etc
> 
> and it is syntactic sugar for:
> 
> flag _unnamed1
> 
> library
>   build-depends: base
>   if flag(_unnamed1)
>     build-depends: base >= 3.0
>     build-depends: pretty, directory, etc
>   else
>     build-depends: !(base >= 3.0)

Your examples use base, for which there will be only one version in a GHC
installation.  But there might be multiple versions of other packages,
so testing on them is a bit more complicated.

How does a repackager control the selection?  (On the other hand, it may
be that flags are to coarse a control for them anyway; they might want
to specify versions or version ranges too.)

> So we still introduce a backtracking point, it's just that now it's
> backtracking without a named flag. This is ok because the decision about
> which branch to take is completely determined once the environment picks
> a version for the dependent package in question.

If this is just sugar for flags, won't it still backtrack just as much?

Also, when one branches on a flag, the first alternative is preferred
if both work.  Presumably this will still be the case, so one might
sometimes have to write an inverted test with an empty then-branch.



More information about the cabal-devel mailing list