[Haskell-cafe] Alternative dependencies in Cabal file

Matthias Reisner matthias.reisner at googlemail.com
Wed Mar 17 09:13:38 EDT 2010


Thanks, I missed that the flags are set dynamically if a dependency 
cannot be satisfied.


Am 17.03.2010 13:23 schrieb Daniel Fischer:
> Am Mittwoch 17 März 2010 12:11:53 schrieb Matthias Reisner:
>> Hi,
>>
>> for a package I need to ensure the user uses a certain package
>> configuration. So how would I rewrite the following pseudo-cabal
>> description?
>>
>>     Build-Depends: packageA < X,           packageB < Y
>>                      or
>>                    packageA >= X && < X',  packageB >= Y && < Y'
>>                      or
>>                    packageA >= X',         packageB >= Y'
>>
>>     Build-Depends: ... common dependencies ...
>>
>> where neither A nor B is the base package. Maybe I have to use if/else
>> blocks, but I don't know what conditions to use then.
>
> Read http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html for a 
> general description of what you can do, I'd try something like in
> http://hackage.haskell.org/packages/archive/cabal-install/0.8.0/cabal-
> install.cabal
>
> flag oldAB
>     description: ancient packages A and B
>     default: False
>
> flag newAB
>     description: shiny new A and B
>
> Library blubb
>     build-depends:
>         common,
>         libraries
>     if flag(newAB)
>         build-depends: packageA >= X', packageB >= Y'
>     else if flag(oldAB)
>         build-depends: packageA < X, packageB < Y
>     else
>         build-depends: packageA >= X && < X', packageB >= Y && < Y'
>
> If I remember correctly, that tries first to build against the new A and B, 
> that failing, it sets flag newAB to false and tries again, first with the 
> not-so-ancient A and B, hopefully (but I'm not sure about the order in 
> which flags are toggled if the defaults don't give a successful install 
> plan).
>
>>
>> Regards,
>>
>> Matthias


More information about the Haskell-Cafe mailing list