[Haskell-cafe] Alternative dependencies in Cabal file

Daniel Fischer daniel.is.fischer at web.de
Wed Mar 17 08:23:47 EDT 2010

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

flag oldAB
    description: ancient packages A and B
    default: False

flag newAB
    description: shiny new A and B

Library blubb
    if flag(newAB)
        build-depends: packageA >= X', packageB >= Y'
    else if flag(oldAB)
        build-depends: packageA < X, packageB < Y
        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 

> Regards,
> Matthias

More information about the Haskell-Cafe mailing list