4

This is actually a follow-on question to How can I tell Cabal which dependency to use?.

The package haskell-src-meta has two dependencies:

template-haskell >=2.7 && <2.9,
template-haskell >=2.4 && <2.7

and template-haskell 2.7 won't build on my system. I know the solution to this is:

cabal install --constraint="template-haskell == 2.5.0.0" haskell-src-meta

However, I now want to write my own cabal file for the software I've written that has these dependencies. It doesn't seem to be enough to have:

Build-depends: template-haskell-2.5.0.0

Instead, I actually want to say that haskell-src-meta is a build dependency, but further tell cabal that it should install that dependency with the same constraint specified above. Is there a way to do this?

Community
  • 1
  • 1
Noah Daniels
  • 355
  • 1
  • 11

1 Answers1

1

Perhaps the "installed" constraint is what you want.

cabal install --constraint "template-haskell installed" my-custom-package
Daniel Wagner
  • 145,880
  • 9
  • 220
  • 380
  • Perhaps, though it seems a shame to have to leak that to all the (imagined) users who install my software. I'd rather they only had to type `cabal install my-app` and be able to bake that `template-haskell` dependency into my cabal file. – Noah Daniels Mar 12 '12 at 22:04
  • 1
    @NoahDaniels Hm. You want to require other people to use `template-haskell-2.5.0.0` because the other versions of `template-haskell` won't build on your computer? That seems like a bad idea, since people should be using the version of `template-haskell` that comes with their compiler, and not attempting to build a different version. – Daniel Wagner Mar 12 '12 at 22:06
  • It appears that `template-haskell` versions are `ghc` version-dependent. What I'd ideally like to do is map `ghc` version to appropriate `template-haskell` version, and solve the problem that way. – Noah Daniels Mar 12 '12 at 22:09
  • 1
    @NoahDaniels It's not yet clear in my head what the problem that you're trying to solve *is*. – Daniel Wagner Mar 12 '12 at 22:10
  • 1
    It seems to be a problem with Hackage. GHC 7.0 comes with `template-haskell-2.5.0.0`, but cabal sees that `template-haskell-2.7.0.0` is on Hackage. So `cabal-install` decides to install `template-haskell-2.7.0.0` when installing `haskell-src-meta`, but this obviously doesn't work, since ghc needs its own version of `template-haskell`. It seems the correct solution would be to remove `template-haskell` from Hackage. – rp123 Mar 12 '12 at 23:37
  • 1
    @reinerp New versions of cabal-install will attempt not to reinstall things (vis-a-vis the "modular" constraint solver). So in the future, such drastic measures may not be necessary. =) – Daniel Wagner Mar 13 '12 at 02:19