Skip to content

Commit 4a84af3

Browse files
committed
Update concluding section of tutorial
1 parent e674653 commit 4a84af3

File tree

3 files changed

+68
-83
lines changed

3 files changed

+68
-83
lines changed

doc/faq.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,9 @@
5252

5353
??? question "How do I use Stack with sandboxes?"
5454

55-
The concept of sandboxes is built-in with Stack. All builds are
56-
automatically isolated into separate package databases.
55+
A 'sandbox' is a development environment that is isolated from other parts
56+
of the system. The concept of sandboxing is built in to Stack. All builds
57+
are automatically isolated into separate package databases.
5758

5859
??? question "Can I run `cabal` commands inside `stack exec`?"
5960

doc/tutorial/stack_configuration.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,45 @@ Keep in mind that there's nothing magical about this implicit global
3131
configuration. It has no effect on projects at all. Every package you install
3232
with it is put into isolated databases just like everywhere else. The only magic
3333
is that it's the catch-all project whenever you're running Stack somewhere else.
34+
35+
## Package description vs project-level configuration
36+
37+
Now that we've covered a lot of ways to use Stack, this quick summary of
38+
package description files versus Stack's project-level configuration file will
39+
hopefully make sense and be a good reminder for future uses of Stack:
40+
41+
<div class="grid cards" markdown>
42+
43+
- __Package description__
44+
45+
Each package has a package description file in the Cabal format (a Cabal
46+
file named after the package.
47+
48+
A package may have a package description file in the Hpack format
49+
(`package.yaml`). If one exists, Stack will use it to generate the Cabal
50+
file.
51+
52+
---
53+
54+
Specifies which other Haskell packages are dependencies of the package.
55+
56+
---
57+
58+
Specifies the components, modules, and Cabal flags provided by the package.
59+
60+
- __Project-level configuration__
61+
62+
Each project has a project-level configuration file (named `stack.yaml`, by
63+
default).
64+
65+
A project can have one or more project packages.
66+
67+
---
68+
69+
Specifies which package versions are available to be used.
70+
71+
---
72+
73+
Can override the Cabal flag settings for individual packages.
74+
75+
</div>

doc/tutorial/tutorial_conclusion.md

Lines changed: 23 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -2,100 +2,42 @@
22

33
# 13. In conclusion
44

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.
278

289
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.
4912

50-
* Cabal (the tool) can use 'curation' too but its origins are in dependency
51-
solving.
13+
Other key features of Stack include:
5214

53-
### Emphasis on reproducibility
15+
<div class="grid cards" markdown>
5416

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__
5818

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.
6221

63-
### Automatic building of dependencies
22+
- __Snapshots__
6423

65-
* Stack's automatically builds dependencies. So for example, in Stack,
66-
`stack test` does the same job as:
24+
---
6725

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.
7429

75-
(newer versions of Cabal (the tool) may make this command sequence shorter).
30+
- __Reproducibility__
7631

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+
---
8033

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.
8236

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__
8638

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+
---
9040

91-
### Tools other than Stack and Cabal (the tool)
41+
Stack automatically builds dependencies.
9242

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

Comments
 (0)