@@ -1665,79 +1665,85 @@ for future uses of Stack:
1665
1665
1666
1666
## Comparison to other tools
1667
1667
1668
- Stack is not the only tool around for building Haskell code. Stack came into
1669
- existence due to limitations with some of the existing tools. If you're
1670
- unaffected by those limitations and are happily building Haskell code, you may
1671
- not need Stack. If you're suffering from some of the common problems in other
1672
- tools, give Stack a try instead.
1673
-
1674
- If you're a new user who has no experience with other tools, we recommend going
1675
- with Stack. The defaults match modern best practices in Haskell development, and
1676
- there are less corner cases you need to be aware of. You * can* develop Haskell
1677
- code with other tools, but you probably want to spend your time writing code,
1678
- not convincing a tool to do what you want.
1679
-
1680
- Before jumping into the differences, let me clarify an important similarity:
1681
-
1682
- __ Same package format.__ Stack, Cabal (the tool), and presumably all other tools
1683
- share the same underlying Cabal package format, consisting of a Cabal file,
1684
- modules, etc. This is a Good Thing: we can share the same set of upstream
1685
- libraries, and collaboratively work on the same project with Stack, Cabal (the
1686
- tool), and NixOS. In that sense, we're sharing the same ecosystem.
1687
-
1688
- Now the differences:
1689
-
1690
- * __ Curation vs dependency solving as a default__ .
1691
- * Stack defaults to using curation (Stackage snapshots, LTS Haskell,
1692
- Nightly, etc) as a default instead of defaulting to dependency solving, as
1693
- Cabal (the tool) does. This is just a default: as described above, Stack
1694
- can use dependency solving if desired, and Cabal (the tool) can use
1695
- curation. However, most users will stick to the defaults. The Stack team
1696
- firmly believes that the majority of users want to simply ignore
1697
- dependency resolution nightmares and get a valid build plan from day one,
1698
- which is why we've made this selection of default behavior.
1699
- * __ Reproducible__ .
1700
- * Stack goes to great lengths to ensure that ` stack build ` today does the
1701
- same thing tomorrow. Cabal (the tool) does not: build plans can be
1702
- affected by the presence of pre-installed packages, and running
1703
- ` cabal update ` can cause a previously successful build to fail. With
1704
- Stack, changing the build plan is always an explicit decision.
1705
- * __ Automatically building dependencies__ .
1706
- * With Cabal (the tool), you need to use ` cabal install ` to trigger
1707
- dependency building. This is somewhat necessary due to the previous point,
1708
- since building dependencies can, in some cases, break existing installed
1709
- packages. So for example, in Stack, ` stack test ` does the same job as
1710
- ` cabal install --run-tests ` , though the latter * additionally* performs an
1711
- installation that you may not want. The closer equivalent command sequence
1712
- is: ` cabal install --enable-tests --only-dependencies ` ,
1713
- ` cabal configure --enable-tests ` , ` cabal build && cabal test ` (newer
1714
- versions of Cabal (the tool) may make this command sequence shorter).
1715
- * __ Isolated by default__ .
1716
- * This has been a pain point for new Stack users. In Cabal, the default
1717
- behavior is a non-isolated build where working on two projects can cause
1718
- the user package database to become corrupted. The Cabal solution to this
1719
- is sandboxes. Stack, however, provides this behavior by default via its
1720
- databases. In other words: when you use Stack, there's __ no need for
1721
- sandboxes__ , everything is (essentially) sandboxed by default.
1722
-
1723
- __ Other tools for comparison (including active and historical)__
1724
-
1725
- * [ cabal-dev] ( https://hackage.haskell.org/package/cabal-dev ) . This is deprecated
1726
- in favor of Cabal (the tool).
1668
+ Stack is not the only tool available for building Haskell code. Stack came into
1669
+ existence due to limitations at that time with some of the existing tools. If
1670
+ you are happily building Haskell code with other tools, you may not need Stack.
1671
+ If you're experiencing problems with other tools, give Stack a try instead.
1672
+
1673
+ If you're a new user who has no experience with other tools, we recommend Stack.
1674
+ The defaults match modern best practices in Haskell development, and there are
1675
+ fewer corner cases you need to be aware of. You * can* develop Haskell code with
1676
+ other tools, but you probably want to spend your time writing code, not
1677
+ convincing a tool to do what you want.
1678
+
1679
+ ### Underlying package format
1680
+
1681
+ Before turning to differences, we clarify an important similarity: Stack, Cabal
1682
+ (the tool), and presumably all other tools share the same underlying package
1683
+ format of Cabal (the library). This is a Good Thing: we can share the same set
1684
+ of upstream libraries, and collaboratively work on the same project with Stack,
1685
+ Cabal (the tool), and NixOS. In that sense, we're sharing the same ecosystem.
1686
+
1687
+ ### Curation vs dependency solving
1688
+
1689
+ * Stack uses 'curation' (snapshots and Stack's project-level configuration file
1690
+ (` stack.yaml ` ) define precisely the set of packages available for a project).
1691
+ The Stack team firmly believes that the majority of users want to simply
1692
+ ignore dependency resolution nightmares and get a valid build plan from day
1693
+ one. That's why we've made 'curation' the focus of Stack.
1694
+
1695
+ * Cabal (the tool) can use 'curation' too but its origins are in dependency
1696
+ solving.
1697
+
1698
+ ### Emphasis on reproducibility
1699
+
1700
+ * Stack goes to great lengths to ensure that ` stack build ` today does the
1701
+ same thing tomorrow. With Stack, changing the build plan is always an explicit
1702
+ decision.
1703
+
1704
+ * Cabal (the tool) does not go to the same lengths: build plans can be affected
1705
+ by the presence of pre-installed packages, and running ` cabal update ` can
1706
+ cause a previously successful build to fail.
1707
+
1708
+ ### Automatic building of dependencies
1709
+
1710
+ * Stack's automatically builds dependencies. So for example, in Stack,
1711
+ ` stack test ` does the same job as:
1712
+
1713
+ ~~~ text
1714
+ cabal install --enable-tests --only-dependencies
1715
+ cabal configure --enable-tests
1716
+ cabal build
1717
+ cabal test
1718
+ ~~~
1719
+
1720
+ (newer versions of Cabal (the tool) may make this command sequence shorter).
1721
+
1722
+ * With Cabal (the tool), you need to use `cabal install` to trigger dependency
1723
+ building. This is somewhat necessary as building dependencies can, in some
1724
+ cases, break existing installed packages.
1725
+
1726
+ ### Isolation
1727
+
1728
+ * Stack is isolated - provides 'sandboxed' behaviour - by default, via its
1729
+ databases. In other words: when you use Stack, there's
1730
+ __no need for sandboxes__, everything is (essentially) sandboxed by default.
1731
+
1732
+ * With Cabal (the tool), the default behavior is a non-isolated build where
1733
+ working on two projects can cause the user package database to become
1734
+ corrupted. The Cabal solution to this is sandboxes.
1735
+
1736
+ ### Tools other than Stack and Cabal (the tool)
1737
+
1727
1738
* [cabal-meta](https://hackage.haskell.org/package/cabal-meta) inspired a lot of
1728
- the multi-package functionality of Stack. If you're still using Cabal (the
1729
- tool), ` cabal-meta ` is relevant. For Stack work, the feature set is fully
1730
- subsumed by Stack.
1731
- * [ cabal-src] ( https://hackage.haskell.org/package/cabal-src ) is mostly
1732
- irrelevant in the presence of both Stack and Cabal sandboxes, both of which
1733
- make it easier to add additional package sources easily. The mega-sdist
1734
- executable that ships with cabal-src is, however, still relevant. Its
1735
- functionality may some day be folded into Stack
1736
- * [ stackage-cli] ( https://hackage.haskell.org/package/stackage-cli ) was an
1737
- initial attempt to make Cabal (the tool) work more easily with curated
1738
- snapshots, but due to a slight impedance mismatch between cabal.config
1739
- constraints and snapshots, it did not work as well as hoped. It is deprecated
1740
- in favor of Stack.
1739
+ the multi-package functionality of Stack. Still relevant for Cabal (the
1740
+ tool).
1741
+ * [cabal-src](https://hackage.haskell.org/package/cabal-src). Deprecated in
1742
+ favor of Stack in 2016.
1743
+ * [stackage-cli](https://hackage.haskell.org/package/stackage-cli).Deprecated
1744
+ in favor of Stack in 2015.
1745
+ * [cabal-dev](https://hackage.haskell.org/package/cabal-dev). Deprecated in
1746
+ favor of Cabal (the tool) in 2013.
1741
1747
1742
1748
## More resources
1743
1749
0 commit comments