[Haskell-cafe] Cabal and more than one version

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Tue Feb 3 04:52:02 EST 2009

On Tue, 2009-02-03 at 10:38 +0100, Sean Leather wrote:
>         Presumably the template-haskell-2.3 package does not build
>         with ghc-6.8
>         but fails to correctly specify the version of base or ghc that
>         it
>         requires. If it did then we would have a better chance to get
>         this
>         right.
> Yes, this is certainly an issue in general with template-haskell-2.3.
> How do we fix this?

We patch the .cabal file in the current darcs version so that its fixed
in the next release.

>         Another possible workaround...
>         If you avoid using the flag hack then the solver would not
>         have to
>         choose so early which version of template-haskell to commit to
>         and it
>         would be able to pick the right version later. Though then you
>         need an
>         alternative method of finding which version of
>         template-haskell you
>         ended up with. You could do it with some custom code in
>         Setup.hs.
> I don't mind using a different approach. How do I detect which version
> of template-haskell I'm using in Setup.lhs that is backwords
> compatible to Cabal 1.2?

You get access to the LocalBuildInfo which contains the packageDeps, the
exact package identifiers. You can find the package you're after and
find its version. Then you can do one of two things. You could generate
a .h file either during post-conf or pre-build or you could add a cpp
option by updating the localPkgDescr in the LocalBuildInfo to add an
extra cpp option.

It's not necessarily short or pretty, but it should be possible to make
it work with Cabal-1.2 and 1.6.


More information about the Haskell-Cafe mailing list