How to check haskell package versions in. / Configure?

how can I tell configure to check version >= xy given Haskell package?

Thanks,

+8
haskell autoconf configure
source share
5 answers

Use cabalvchk: http://hackage.haskell.org/package/cabalvchk-0.2

For example, to make sure the parsec version is> = 0.4, you can specify:

 $ cabalvchk parsec '>= 0.4' 

The return code will be zero if the version restriction is met and otherwise is nonzero. The limitation of the version can be understood in some way understandable. The optional third parameter may not be empty to request verbose output.

+5
source share

I don't know much about configure ; can you ask him to execute a specific command? If so, then ghc-pkg latest should help you. For example, here it runs on my computer for the zlib package:

 % ghc-pkg latest zlib zlib-0.5.3.1 % ghc-pkg latest --global zlib zlib-0.5.3.1 % ghc-pkg latest --user zlib ghc-pkg: cannot find package zlib zsh: exit 1 ghc-pkg latest --user zlib 

--global should be used for system-wide installations and should not be flagged at all for custom installations. The --user flag should be used only when you want to check if the user has a local package installation (which can override the global one).

If you have no reason, I recommend disabling configure in favor of cabal . For cabal solution here is to first cabal init in your project directory, and then check that you have such a line in the created .cabal file:

 build-depends: zlib >= 0.5 

The cabal is the standard for Haskell projects (as it automates and simplifies many things, including the needle). You can also request cabal to call configure if there are other dependencies. If you need more information about this, open a separate question.

+3
source share

Perhaps the best question is: isn’t it? Checking for a specific version number is one of the greatest arguments in the autoconf world, and the overall winner of the discussion is the side that says you should never do this. What Haskell feature do you need? Try it out. As a simple example (not related to haskell), suppose your program uses inotify, so you want the configuration to check if it is available. You can simply check if there is a kernel version> 2,6.13, but then when Joe tries to create your program on his version 2.4.xx, in which he fixed the inotify features, he will be really annoyed that your program will not work.

You don't care if Haskell> xy is available. Instead, there is a specific Haskell feature that you want it to be introduced into xy; check this feature.

+1
source share

Using ghc-pkg list , you can list the installed versions of the package in ascending order. You can probably filter this list for a match. (I do not know how to do this with configure , sorry).

 $ ghc-pkg list yesod /home/ahammar/.haskell/lib/ghc-7.0.2/package.conf.d /home/ahammar/.ghc/x86_64-linux-7.0.2/package.conf.d yesod-0.8.2.1 yesod-0.9.1 yesod-0.9.2.2 
0
source share

Try something like this:

 # Find ghc-pkg, so we can do version checks AC_ARG_VAR([GHC_PKG], [Path to ghc-pkg]) AC_PATH_PROG([GHC_PKG], [ghc-pkg]) AS_IF([test -z "$GHC_PKG"], [AC_MSG_ERROR([Cannot find ghc-pkg.])]) # Check that the package actually exists AC_MSG_CHECKING([for Haskell package foo]) AS_IF([$GHC_PKG latest foo > /dev/null 2>&1], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no]) AC_MSG_ERROR([Cannot find foo])]) # Check its version AC_MSG_CHECKING([if foo is new enough]) foo_ver=`$GHC_PKG latest foo | sed 's/^foo-//'` # At this point you have the version of foo and the minimum version you want. # The rest of the test is pretty easy to write, use cut and test to compare the # version numbers. If it new enough, AC_MSG_RESULT([yes]). # If not, AC_MSG_RESULT([no]) and AC_MSG_ERROR([foo is not new enough.]) 
0
source share

All Articles