Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell: Testing a package against multiple versions of base for Hackage

I'm trying to upload my first package to Hackage (yay!), and I got this error:

The dependency 'build-depends: base' does not specify an upper bound on the version number. Each major release of the 'base' package changes the API in various ways and most packages will need some changes to compile with it. The recommended practise is to specify an upper bound on the version of the 'base' package. This ensures your package will continue to build when a new major version of the 'base' package is released. If you are not sure what upper bound to use then use the next major version. For example if you have tested your package with 'base' version 2 and 3 then use 'build-depends: base >= 2 && < 4'.

Which seems like a perfectly acceptable reason to decline my package.

Is there a good tool to test my package against various versions of base so I can see what the bounds are (rather than just guessing)? The best I can think of is to use some shell scripting to do something like:

% for v in $BASE_VERSIONS
do
  cabal install base-$v &&\
  cabal configure --enable-tests &&\
  cabal build &&\
  cabal test && echo "$v ok" || echo "$v fail"
done

But I feel like there should be something better.

like image 975
rampion Avatar asked Dec 27 '11 14:12

rampion


1 Answers

This is a very bad idea! You must not upgrade base or any other packages that come with GHC (the ones with - in the tag column), or everything will break horribly.

The only way to test with an older version of base is to install an older GHC and test with that. I would suggest just trying it on 7.0.4 and 7.2.2; supporting older versions is probably a waste of time these days.

Failing that, just specify base >= VERSION && < 5, where VERSION is the version your GHC has. Or base == 4.* and hope for the best :)

In all seriousness, base's API doesn't really change all that much, so you're unlikely to run into many problems with this.

For testing your program with various versions of packages in general without disturbing your main ~/.cabal repository, I strongly recommend cabal-dev; something like

$ cabal-dev install 'pkg==VERSION'
$ cabal-dev install
$ cabal-dev test

should do it.

By the way, you can do cabal check to get warned about problems like this before uploading your package to Hackage.

like image 148
ehird Avatar answered Oct 10 '22 07:10

ehird