2
2
3
3
# The Haskell Tool Stack
4
4
5
- Stack is a cross-platform program for developing
6
- [ Haskell] ( https://www.haskell.org/ ) projects. It is aimed at Haskellers both new
7
- and experienced. It aims to support fully users on Linux, macOS and Windows.
5
+ Welcome to the [ Haskell] ( https://www.haskell.org/ ) programming language and the
6
+ Haskell Tool Stack (Stack)! Stack is a program for developing Haskell projects.
7
+ It is aimed at Haskellers both new and experienced. It is cross-platform and
8
+ aims to support fully users on Linux, macOS and Windows.
8
9
9
10
<img src =" https://i.imgur.com/WW69oTj.gif " width =" 50% " align =" right " >
10
11
@@ -19,35 +20,47 @@ Stack features:
19
20
20
21
## How to install Stack
21
22
22
- Stack can be installed on most Unix-like operating systems, including macOS, and
23
+ Stack can be installed on most Unix-like operating systems ( including macOS) and
23
24
on Windows.
24
25
25
- For most Unix-like operating systems, the easiest way to install Stack is to
26
- command:
26
+ === "Unix-like"
27
27
28
- ~~~ text
29
- curl -sSL https://get.haskellstack.org/ | sh
30
- ~~~
28
+ For most Unix-like operating systems, the easiest way to install Stack is to
29
+ command:
31
30
32
- or:
31
+ ~~~text
32
+ curl -sSL https://get.haskellstack.org/ | sh
33
+ ~~~
33
34
34
- ~~~ text
35
- wget -qO- https://get.haskellstack.org/ | sh
36
- ~~~
35
+ or:
36
+
37
+ ~~~text
38
+ wget -qO- https://get.haskellstack.org/ | sh
39
+ ~~~
40
+
41
+ !!! note
42
+
43
+ The script at [get.haskellstack.org](https://get.haskellstack.org/) will
44
+ ask for root access using `sudo`. It needs such access in order to use
45
+ your platform's package manager to install dependencies and to install
46
+ to `/usr/local/bin`. If you prefer more control, follow the manual
47
+ installation instructions in the
48
+ [install and upgrade guide](install_and_upgrade.md).
49
+
50
+ === "Windows"
51
+
52
+ On 64-bit Windows, you can download and install the
53
+ [Windows installer](https://get.haskellstack.org/stable/windows-x86_64-installer.exe).
37
54
38
- On 64-bit Windows, you can download and install the
39
- [ Windows installer] ( https://get.haskellstack.org/stable/windows-x86_64-installer.exe ) .
40
- Note that systems with antivirus software may need to add Stack to the list of
41
- 'trusted' applications.
55
+ !!! note
42
56
43
- For other operating systems and direct downloads, check out the
44
- [ install and upgrade guide ] ( install_and_upgrade.md ) .
57
+ Systems with antivirus software may need to add Stack to the list of
58
+ 'trusted' applications .
45
59
46
- The [ get.haskellstack.org] ( https://get.haskellstack.org/ ) script referred to
47
- above will ask for root access using ` sudo ` . It needs such access in order to
48
- use your platform's package manager to install dependencies and to install to
49
- ` /usr/local/bin ` . If you prefer more control, follow the manual installation
50
- instructions in the [ install and upgrade guide] ( install_and_upgrade.md ) .
60
+ === "Other/direct downloads"
61
+
62
+ For other operating systems and direct downloads, see the
63
+ [install and upgrade guide](install_and_upgrade.md).
51
64
52
65
## How to upgrade Stack
53
66
@@ -63,7 +76,7 @@ stack upgrade
63
76
For an immediate experience of using Stack to build an executable with Haskell,
64
77
first you need to follow the [ guide to install Stack] ( #how-to-install-Stack ) .
65
78
66
- ### Start your new project
79
+ ### Step 1: Start your new project
67
80
68
81
To start a new project named ` my-project ` , issue these four commands in a
69
82
terminal:
@@ -76,13 +89,14 @@ stack exec my-project-exe
76
89
~~~
77
90
78
91
- The ` stack new my-project ` command will create a new directory, named
79
- ` my-project ` , that contains all the files needed to start a project correctly,
92
+ ` my-project ` . It contains all the files needed to start a project correctly,
80
93
using a default template.
81
- - The ` cd my-project ` command will change to that directory.
94
+ - The ` cd my-project ` command will change the current working directory to that
95
+ directory.
82
96
- The ` stack build ` command will build the template project and create an
83
- executable named ` my-project-exe ` . First, if necessary, Stack will download
84
- the necessary GHC compiler in an isolated location. That won't interfere with
85
- any system-level installations of GHC.
97
+ executable named ` my-project-exe ` (on Windows, ` my-project-exe.exe ` ). First,
98
+ if necessary, Stack will download a version of GHC in an isolated location.
99
+ That won't interfere with other GHC instalations on your system .
86
100
- The ` stack exec my-project-exe ` command will run (execute) the built
87
101
executable, in Stack's environment.
88
102
@@ -98,23 +112,27 @@ For help on a particular Stack command, for example `stack build`, command:
98
112
stack build --help
99
113
~~~
100
114
101
- If you want to launch a run-eval-print loop (REPL), then command:
115
+ If you want to launch a run-eval-print loop (REPL) environment , then command:
102
116
103
117
~~~ text
104
- stack ghci
118
+ stack repl
105
119
~~~
106
120
107
- If you want to use Stack to install an executable provided by a Haskell package,
108
- then all you have to do is command:
121
+ !!! info
122
+
123
+ `stack ghci` can be used instead of `stack repl`. GHCi is GHC's REPL tool.
124
+
125
+ People organise Haskell code into packages. If you want to use Stack to install
126
+ an executable provided by a Haskell package, then all you have to do is command:
109
127
110
128
~~~ text
111
129
stack install <package-name>
112
130
~~~
113
131
114
- ### Workflow
132
+ ### Step 2: Next steps
115
133
116
- The ` stack new my-project ` command above should have created the following files
117
- and directories:
134
+ The ` stack new my-project ` command in step one should have created the following
135
+ files and directories (among others) :
118
136
119
137
~~~ text
120
138
.
@@ -124,47 +142,43 @@ and directories:
124
142
│ └── Lib.hs
125
143
├── test
126
144
│ └── Spec.hs
127
- ├── Setup.hs
128
- ├── package.yaml
129
145
├── my-project.cabal
130
- ├── stack.yaml
131
- ├── README.md
132
- ├── ChangeLog.md
133
- ├── LICENSE
134
- └── .gitignore
146
+ ├── package.yaml
147
+ └── stack.yaml
135
148
~~~
136
149
137
- (The ` stack build ` command will have created other directories and files.)
150
+ The Haskell source code for the executable (application) is in file ` Main.hs ` .
151
+
152
+ The executable uses a library. Its source code is in file ` Lib.hs ` .
138
153
139
- The Haskell code for the executable/application is in ` Main.hs ` . The
140
- source code for the library that it uses is in ` Lib.hs ` . The contents of
141
- ` my-project.cabal ` describes the project. That file is generated by the contents
142
- of ` package.yaml ` .
154
+ The contents of ` my-project.cabal ` describes the project. That file is generated
155
+ by the contents of ` package.yaml ` .
143
156
144
- To manage your library:
157
+ !!! info
145
158
146
- 1 . Edit source files in the ` src ` directory. The ` app ` directory should
147
- preferably contain only files related to executables .
159
+ If you want, you can delete the `package.yaml` file and update the
160
+ `my-project.cabal` file directly. Stack will then use that file .
148
161
149
- 2 . Your developing project may need to depend on a library provided by another
150
- Haskell package .
162
+ You can edit the source files in the ` src ` directory (used for the library) or
163
+ the ` app ` directory (used for the executable (application)) .
151
164
152
- - Add the name of that new package to the file ` package.yaml ` , in its
153
- ` dependencies: ` section.
154
- - Run ` stack build ` again. Stack will use ` package.yaml ` to create an
155
- updated ` my-project.cabal ` for you.
165
+ As your project develops, you may need to depend on a library provided by
166
+ another Haskell package. If you do, then add the name of that new package to the
167
+ file ` package.yaml ` , in its ` dependencies: ` section.
156
168
157
- 3 . If desired, you can delete the ` package.yaml ` file and update the
158
- ` my-project.cabal ` file directly. Stack will then use that file.
169
+ !!! info
159
170
160
- 4 . If you get an error message that tells you that the Stack configuration has
161
- no specified version of your added package, follow Stack's likely
162
- recommandation to add a specific version of that package in the ` stack.yaml `
163
- file, in its ` extra-deps: ` section.
171
+ When you use `stack build` again, Stack will use `package.yaml` to create an
172
+ updated `my-project.cabal` for you.
173
+
174
+ If Stack reports that the Stack configuration has no specified version for the
175
+ new package, then follow Stack's likely recommended action to add a specific
176
+ version of that package your project's ` stack.yaml ` file, in its ` extra-deps: `
177
+ section.
164
178
165
179
That was a really fast introduction on how to start to code in Haskell using
166
180
Stack. If you want to go further, we highly recommend you read Stack's
167
- [ user's guide] ( GUIDE.md ) .
181
+ introductory [ user's guide] ( GUIDE.md ) .
168
182
169
183
## Complete guide to Stack
170
184
@@ -174,32 +188,40 @@ explained in the [glossary](glossary.md).
174
188
175
189
## Why Stack?
176
190
177
- Stack is a build tool for Haskell designed to answer the needs of Haskell users
178
- new and experienced alike. It has a strong focus on reproducible build plans,
179
- multi-package projects, and a consistent, easy-to-learn interface, while
180
- providing the customizability and power experienced developers need.
191
+ Stack is a build tool for Haskell designed to answer the needs of Haskell users,
192
+ both new and experienced. It has a strong focus on reproducible build plans,
193
+ multi-package projects, and a consistent, easy-to-learn set of Stack commands.
194
+ It also aims to provide the customizability and power that experienced
195
+ developers need.
181
196
182
- As a build tool, Stack does not stand alone. It is built on the great work
183
- provided by:
197
+ Stack does not stand alone. It is built on the great work provided by:
184
198
185
199
* The __ Glasgow Haskell Compiler__ ([ GHC] ( https://www.haskell.org/ghc/ ) ), the
186
200
premier Haskell compiler. Stack will manage your GHC installations and
187
- automatically select the appropriate compiler version for your project.
188
- * The __ Cabal build system__ , a specification for defining Haskell packages,
189
- together with a [ library] ( https://hackage.haskell.org/package/Cabal ) for
201
+ automatically select the appropriate version of GHC for your project.
202
+ * The __ Cabal build system__ . Cabal is a specification for defining Haskell
203
+ packages and a [ library] ( https://hackage.haskell.org/package/Cabal ) for
190
204
performing builds.
205
+
206
+ !!! info
207
+
208
+ Cabal is also the name of another build tool, provided by the
209
+ `cabal-install` package. This guide distinguishes between them by Cabal
210
+ (the library) and Cabal (the tool).
211
+
191
212
* The __ Hackage Haskell Package Repository__ , a
192
- [ repository] ( https://hackage.haskell.org/ ) providing thousands of open source
193
- libraries and applications to help you get your work done.
194
- * The __ Stackage package collection__ , a
195
- [ curated set of packages] ( https://www.stackage.org/ ) from Hackage which are
196
- regularly tested for compatibility. Stack defaults to using Stackage
197
- package sets to avoid dependency problems.
213
+ [ repository] ( https://hackage.haskell.org/ ) of Haskell packages providing
214
+ thousands of open source libraries and applications to help you get your work
215
+ done.
216
+ * The __ Stackage package collection__ , sets of packages from Hackage that are
217
+ [ curated] ( https://www.stackage.org/ ) . That is, they are regularly tested for
218
+ compatibility. Stack defaults to using Stackage package sets to avoid
219
+ problems with incompatible dependencies.
198
220
199
221
Stack is provided by a team of volunteers and companies under the auspices of
200
222
the [ Commercial Haskell] ( http://commercialhaskell.com/ ) group. The project was
201
223
spearheaded by [ FP Complete] ( https://www.fpcomplete.com/ ) to answer the needs of
202
- commercial Haskell users, and has since become a thriving open source project
224
+ commercial Haskell users. It has since become a thriving open source project
203
225
meeting the needs of Haskell users of all stripes.
204
226
205
227
If you'd like to get involved with Stack, check out the
@@ -222,21 +244,48 @@ label on the GitHub issue tracker.
222
244
The following assumes that you already have installed a version of Stack and the
223
245
[ Git application] ( https://git-scm.com/ ) .
224
246
225
- 1 . Clone the ` stack ` repository from GitHub with the command:
226
- ` git clone https://github.com/commercialhaskell/stack.git ` .
227
- 2 . Enter into the cloned ` stack ` directory with command ` cd stack ` .
228
- 3 . Build the ` stack ` executable using a pre-existing installation of Stack with
229
- command ` stack build ` .
230
- 4 . Once the ` stack ` executable has been built, check its version with the
231
- command ` stack exec -- stack --version ` . Make sure the version is the latest.
232
- 5 . In the GitHub respository's issue tracker, look for issues tagged with
233
- [ newcomer friendly] ( https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3a%22newcomer+friendly%22 )
234
- and
235
- [ awaiting pull request] ( https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3A%22awaiting+pull+request%22 )
236
- labels.
237
-
238
- If you need to check your changes quickly run ` stack ghci ` and then this command
239
- at the REPL's prompt:
247
+ 1 . Clone the ` stack ` repository from GitHub with the command:
248
+
249
+ ~~~ text
250
+ git clone https://github.com/commercialhaskell/stack.git`
251
+ ~~~
252
+
253
+ 2. Change the current working directory to the cloned `stack` directory with the
254
+ command:
255
+
256
+ ~~~text
257
+ cd stack
258
+ ~~~
259
+
260
+ 3. Build the `stack` executable using a pre-existing installation of Stack with
261
+ the command:
262
+
263
+ ~~~text
264
+ stack build
265
+ ~~~
266
+
267
+ 4. Once the `stack` executable has been built, check its version with the
268
+ command:
269
+
270
+ ~~~text
271
+ stack exec -- stack --version
272
+ ~~~
273
+
274
+ Make sure the version is the latest one.
275
+
276
+ 5. In the GitHub respository's issue tracker, look for issues tagged with
277
+ [newcomer friendly](https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3a%22newcomer+friendly%22)
278
+ and
279
+ [awaiting pull request](https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3A%22awaiting+pull+request%22)
280
+ labels.
281
+
282
+ If you need to check your changes quickly command:
283
+
284
+ ~~~text
285
+ stack repl
286
+ ~~~
287
+
288
+ and then, at the REPL's prompt, command:
240
289
241
290
~~~ text
242
291
:main --stack-root=<path_to_root> --stack-yaml=<path_to_stack.yaml> <COMMAND>
0 commit comments