Search code examples
haskellcabalhaskell-stack

Cabal + Stack: specifying the packages version in the cabal file


Normally when adding a new dependency to a .cabal file I specify the version of the new library I'm depending on. However stack works with a curated set of libraries, and I'm wondering whether it makes sense to specify the package versions in the .cabal file. My guess would be that specifying the lts version in the stack.yaml is enough.


Solution

  • I'm wondering whether it makes sense to specify the package versions in the .cabal file.

    That depends completely upon you. If you specify a package version which is not in that particular stackage resolver, then Stack will throw an error saying you to adjust the versioning.

    My guess would be that specifying the lts version in the stack.yaml is enough.

    For private packages, it doesn't matter and I prefer not putting any version bounds there. But if it's something I ultimately plan to publish on Hackage, I usually use a CI system like Travis and get the bounds right for it with some testing. In fact, I think the Stack guide recommends something like that.