Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Either A or B" dependency in Cabal

Tags:

haskell

cabal

In one of my packages, I semi-recently added an overly strict dependency version constraint to work around a bug in that particular version of the package. However, as new versions of other packages have been released, this is now causing dependency conflicts for some of my users. One of them helpfully suggested to replace the current, overly strict, constraint zip-archive == 0.2 with something along the lines of (zip-archive <= 0.2.3 && binary >= 0.5) || (zip-archive >= 0.2.3.1 && binary >= 0.7) - that is, depend either on A or on B, and we don't really care which one.

Is there a way to express this in Cabal?

like image 759
valderman Avatar asked Jul 04 '14 09:07

valderman


1 Answers

While I haven't verified this, I think you can do it using a flag:

flag someName
  default: True

library
  if flag(someName)
    build-depends:
      zip-archive >= 0.2.3.1,
      binary >= 0.7
  else
    build-depends:
      zip-archive <= 0.2.3,
      binary >= 0.5

The solver will pick the branch that makes the overall constraint problem solvable.

like image 81
tibbe Avatar answered Oct 05 '22 23:10

tibbe