|
2 | 2 |
|
3 | 3 | # 13. In conclusion |
4 | 4 |
|
5 | | -## `stack.yaml` versus Cabal files |
6 | | - |
7 | | -Now that we've covered a lot of Stack use cases, this quick summary of |
8 | | -`stack.yaml` versus Cabal files will hopefully make sense and be a good reminder |
9 | | -for future uses of Stack: |
10 | | - |
11 | | -* A project can have multiple packages. |
12 | | -* Each project has a `stack.yaml`. |
13 | | -* Each package has a Cabal file, named `<package_name>.cabal`. |
14 | | -* The Cabal file specifies which packages are dependencies. |
15 | | -* The `stack.yaml` file specifies which packages are available to be used. |
16 | | -* The Cabal file specifies the components, modules, and build flags provided by |
17 | | - a package |
18 | | -* `stack.yaml` can override the flag settings for individual packages |
19 | | -* `stack.yaml` specifies which packages to include |
20 | | - |
21 | | -## Comparison to other tools |
22 | | - |
23 | | -Stack is not the only tool available for building Haskell code. Stack came into |
24 | | -existence due to limitations at that time with some of the existing tools. If |
25 | | -you are happily building Haskell code with other tools, you may not need Stack. |
26 | | -If you're experiencing problems with other tools, give Stack a try instead. |
| 5 | +Stack is not the only tool available for building Haskell code. If you are |
| 6 | +happy building Haskell code with other tools, you may not need Stack. If |
| 7 | +you're experiencing problems with other tools, give Stack a try. |
27 | 8 |
|
28 | 9 | If you're a new user who has no experience with other tools, we recommend Stack. |
29 | | -The defaults match modern best practices in Haskell development, and there are |
30 | | -fewer corner cases you need to be aware of. You *can* develop Haskell code with |
31 | | -other tools, but you probably want to spend your time writing code, not |
32 | | -convincing a tool to do what you want. |
33 | | - |
34 | | -### Underlying package format |
35 | | - |
36 | | -Before turning to differences, we clarify an important similarity: Stack, Cabal |
37 | | -(the tool), and presumably all other tools share the same underlying package |
38 | | -format of Cabal (the library). This is a Good Thing: we can share the same set |
39 | | -of upstream libraries, and collaboratively work on the same project with Stack, |
40 | | -Cabal (the tool), and NixOS. In that sense, we're sharing the same ecosystem. |
41 | | - |
42 | | -### Curation vs dependency solving |
43 | | - |
44 | | -* Stack uses 'curation' (snapshots and Stack's project-level configuration file |
45 | | - (`stack.yaml`, by default) define precisely the set of packages available for |
46 | | - a project). The Stack team firmly believes that the majority of users want to |
47 | | - simply ignore dependency resolution nightmares and get a valid build plan from |
48 | | - day one. That's why we've made 'curation' the focus of Stack. |
| 10 | +It aims to be easy to use and its defaults match modern best practices in |
| 11 | +Haskell development. |
49 | 12 |
|
50 | | -* Cabal (the tool) can use 'curation' too but its origins are in dependency |
51 | | - solving. |
| 13 | +Other key features of Stack include: |
52 | 14 |
|
53 | | -### Emphasis on reproducibility |
| 15 | +<div class="grid cards" markdown> |
54 | 16 |
|
55 | | -* Stack goes to great lengths to ensure that `stack build` today does the |
56 | | - same thing tomorrow. With Stack, changing the build plan is always an explicit |
57 | | - decision. |
| 17 | +- __Sandboxing__ |
58 | 18 |
|
59 | | -* Cabal (the tool) does not go to the same lengths: build plans can be affected |
60 | | - by the presence of pre-installed packages, and running `cabal update` can |
61 | | - cause a previously successful build to fail. |
| 19 | + A 'sandbox' is a development environment that is isolated from other parts |
| 20 | + of the system. The concept of sandboxing is built in to Stack. |
62 | 21 |
|
63 | | -### Automatic building of dependencies |
| 22 | +- __Snapshots__ |
64 | 23 |
|
65 | | -* Stack's automatically builds dependencies. So for example, in Stack, |
66 | | - `stack test` does the same job as: |
| 24 | + --- |
67 | 25 |
|
68 | | - ~~~text |
69 | | - cabal install --enable-tests --only-dependencies |
70 | | - cabal configure --enable-tests |
71 | | - cabal build |
72 | | - cabal test |
73 | | - ~~~ |
| 26 | + A snapshot specifies a GHC versions and a set of package versions that work |
| 27 | + well together. Stack uses snapshots to define precisely the set of package |
| 28 | + versions available for a project. |
74 | 29 |
|
75 | | - (newer versions of Cabal (the tool) may make this command sequence shorter). |
| 30 | +- __Reproducibility__ |
76 | 31 |
|
77 | | -* With Cabal (the tool), you need to use `cabal install` to trigger dependency |
78 | | - building. This is somewhat necessary as building dependencies can, in some |
79 | | - cases, break existing installed packages. |
| 32 | + --- |
80 | 33 |
|
81 | | -### Isolation |
| 34 | + Stack goes to great lengths to ensure that `stack build` today does the |
| 35 | + same thing tomorrow. Changing the build plan is always an explicit decision. |
82 | 36 |
|
83 | | -* Stack is isolated - provides 'sandboxed' behaviour - by default, via its |
84 | | - databases. In other words: when you use Stack, there's |
85 | | - __no need for sandboxes__, everything is (essentially) sandboxed by default. |
| 37 | +- __Building dependencies__ |
86 | 38 |
|
87 | | -* With Cabal (the tool), the default behavior is a non-isolated build where |
88 | | - working on two projects can cause the user package database to become |
89 | | - corrupted. The Cabal solution to this is sandboxes. |
| 39 | + --- |
90 | 40 |
|
91 | | -### Tools other than Stack and Cabal (the tool) |
| 41 | + Stack automatically builds dependencies. |
92 | 42 |
|
93 | | -* [cabal-meta](https://hackage.haskell.org/package/cabal-meta) inspired a lot of |
94 | | - the multi-package functionality of Stack. Still relevant for Cabal (the |
95 | | - tool). |
96 | | -* [cabal-src](https://hackage.haskell.org/package/cabal-src). Deprecated in |
97 | | - favor of Stack in 2016. |
98 | | -* [stackage-cli](https://hackage.haskell.org/package/stackage-cli).Deprecated |
99 | | - in favor of Stack in 2015. |
100 | | -* [cabal-dev](https://hackage.haskell.org/package/cabal-dev). Deprecated in |
101 | | - favor of Cabal (the tool) in 2013. |
| 43 | +</div> |
0 commit comments