Cabal和Stack有什么区别? [英] What is the difference between Cabal and Stack?
问题描述
Stack是Cabal的替代品吗?
是和否。
哪些情况下我应该使用Stack而不是Cabal? Stack可以做到Cabal不能做什么?
自 Stack
使用由 default 管理的堆栈包,已知包可以一起构建。在卡巴尔,你有可能受到阴谋地狱的袭击。 Stack也会在本地缓存你的包,这样你下一次使用该包时(或者它是传递依赖)就不会从头开始编译所有的东西。请注意,还提供了使用非堆栈包的条款,所以即使堆栈快照中不存在包,也可以使用。
就我个人而言,我喜欢堆栈。他们的发展很快。他们并不担心(那么多)向后兼容性。它有一个更好的用户体验。还有一些是 stack
没有提供 Cabal
的事情:
- Stack甚至可以为您下载GHC并将其保存在隔离位置中。
- Docker支持
- 可复制的Haskell脚本:您可以精确定位包的版本,可以保证它总能正常执行而不会出现任何问题。
- 能够执行
stack build --fast --file-watch
。如果您更改当前的本地文件,这将自动重建。
- 能够指定外部git存储库 / strong>作为依赖项。
- Stack支持使用模板创建项目。它还支持您自己的自定义模板。
- Stack内置 hpack 支持。它提供了一种编写cabal文件的替代方法(IMO,更好)。 /master/TOOLING.mdrel =nofollow noreferrer>当使用堆栈时。
博客文章解释不同之处:为什么Stack不是Cabal?
Yesterday I learnt about a new Haskell tool called Stack. At the first blush, it looks like it does much the same job as Cabal. So, what is the difference between them? Is stack a replacement for Cabal? In which cases should I use Stack instead of Cabal? What can Stack do that Cabal can't?
Is stack a replacement for Cabal?
Yes and No.
In which cases should I use Stack instead of Cabal? What can Stack do that Cabal can't?
Since Stack
uses the curated stackage packages by default, the packages are known to build together. In Cabal, there is a chance that you may get hit with cabal hell. Stack also locally caches your package, so that you don't compile everything from scratch when you use that package (or it's transitive dependency) next time. Note that there is also provision for using non stackage packages, so you are good to go even if a package isn't present in the stackage snapshot.
Personally, I like Stack. Their development is fast. They don't worry (that much) about backwards compatibility. And it has a much better UX. And there are things which stack
does which Cabal
yet doesn't provide:
- Stack even downloads GHC for you and keeps it in an isolated location.
- Docker support
- Reproducible Haskell script: You can pinpoint version of a package and can get guarantee that it will always execute without any problem.
- Ability to do
stack build --fast --file-watch
. This will automatically rebuild if you change the local files present. Using it along with--pedantic
option is a deal-breaker for me. - Ability to specify external git repository as an dependency.
- Stack supports creating projects using templates. It also supports your own custom templates.
- Stack has built-in hpack support in it. It provides an alternative (IMO, a better) way of writing cabal files.
- Intero has a smooth experience when working with Stack.
There is a nice blog post explaining the difference: Why is Stack not Cabal?
这篇关于Cabal和Stack有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!