Cabal + Stack:在 cabal 文件中指定包版本

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

通常在向 .cabal 文件添加新的依赖项时,我会指定我所依赖的新库的版本。但是 stack 与一组精选的库一起使用,我想知道在 .cabal 文件中指定包版本是否有意义。我的猜测是在 stack.yaml 中指定 lts 版本就足够了。

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

这完全取决于你。如果您指定包版本 它不在那个特定的堆栈解析器中,那么 Stack 将 抛出错误提示您调整版本控制。

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

对于私有包,这无关紧要,我不希望在那里设置任何版本界限。但如果这是我最终计划在 Hackage 上发布的东西,我通常会使用 CI system like Travis 并通过一些测试获得适合它的界限。事实上,我认为 Stack 指南推荐了类似的东西。