@@ -76,7 +76,7 @@ stack upgrade
76
76
For an immediate experience of using Stack to build an executable with Haskell,
77
77
first you need to follow the [ guide to install Stack] ( #how-to-install-Stack ) .
78
78
79
- ### Start your new project
79
+ ### Step 1: Start your new project
80
80
81
81
To start a new project named ` my-project ` , issue these four commands in a
82
82
terminal:
@@ -89,13 +89,14 @@ stack exec my-project-exe
89
89
~~~
90
90
91
91
- The ` stack new my-project ` command will create a new directory, named
92
- ` 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,
93
93
using a default template.
94
- - 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.
95
96
- The ` stack build ` command will build the template project and create an
96
- executable named ` my-project-exe ` . First, if necessary, Stack will download
97
- the necessary GHC compiler in an isolated location. That won't interfere with
98
- 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 .
99
100
- The ` stack exec my-project-exe ` command will run (execute) the built
100
101
executable, in Stack's environment.
101
102
@@ -111,23 +112,27 @@ For help on a particular Stack command, for example `stack build`, command:
111
112
stack build --help
112
113
~~~
113
114
114
- 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:
115
116
116
117
~~~ text
117
- stack ghci
118
+ stack repl
118
119
~~~
119
120
120
- If you want to use Stack to install an executable provided by a Haskell package,
121
- 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:
122
127
123
128
~~~ text
124
129
stack install <package-name>
125
130
~~~
126
131
127
- ### Workflow
132
+ ### Step 2: Next steps
128
133
129
- The ` stack new my-project ` command above should have created the following files
130
- and directories:
134
+ The ` stack new my-project ` command in step one should have created the following
135
+ files and directories (among others) :
131
136
132
137
~~~ text
133
138
.
@@ -137,47 +142,43 @@ and directories:
137
142
│ └── Lib.hs
138
143
├── test
139
144
│ └── Spec.hs
140
- ├── Setup.hs
141
- ├── package.yaml
142
145
├── my-project.cabal
143
- ├── stack.yaml
144
- ├── README.md
145
- ├── ChangeLog.md
146
- ├── LICENSE
147
- └── .gitignore
146
+ ├── package.yaml
147
+ └── stack.yaml
148
148
~~~
149
149
150
- ( 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
151
152
- The Haskell code for the executable/application is in ` Main.hs ` . The
153
- source code for the library that it uses is in ` Lib.hs ` . The contents of
154
- ` my-project.cabal ` describes the project. That file is generated by the contents
155
- of ` package.yaml ` .
152
+ The executable uses a library. Its source code is in file ` Lib.hs ` .
156
153
157
- To manage your library:
154
+ The contents of ` my-project.cabal ` describes the project. That file is generated
155
+ by the contents of ` package.yaml ` .
158
156
159
- 1 . Edit source files in the ` src ` directory. The ` app ` directory should
160
- preferably contain only files related to executables.
157
+ !!! info
161
158
162
- 2 . Your developing project may need to depend on a library provided by another
163
- Haskell package .
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 .
164
161
165
- - Add the name of that new package to the file ` package.yaml ` , in its
166
- ` dependencies: ` section.
167
- - Run ` stack build ` again. Stack will use ` package.yaml ` to create an
168
- updated ` my-project.cabal ` for you.
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)).
169
164
170
- 3 . If desired, you can delete the ` package.yaml ` file and update the
171
- ` my-project.cabal ` file directly. Stack will then use that file.
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.
172
168
173
- 4 . If you get an error message that tells you that the Stack configuration has
174
- no specified version of your added package, follow Stack's likely
175
- recommandation to add a specific version of that package in the ` stack.yaml `
176
- file, in its ` extra-deps: ` section.
169
+ !!! info
170
+
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.
177
178
178
179
That was a really fast introduction on how to start to code in Haskell using
179
180
Stack. If you want to go further, we highly recommend you read Stack's
180
- [ user's guide] ( GUIDE.md ) .
181
+ introductory [ user's guide] ( GUIDE.md ) .
181
182
182
183
## Complete guide to Stack
183
184
@@ -187,32 +188,40 @@ explained in the [glossary](glossary.md).
187
188
188
189
## Why Stack?
189
190
190
- Stack is a build tool for Haskell designed to answer the needs of Haskell users
191
- new and experienced alike. It has a strong focus on reproducible build plans,
192
- multi-package projects, and a consistent, easy-to-learn interface, while
193
- 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.
194
196
195
- As a build tool, Stack does not stand alone. It is built on the great work
196
- provided by:
197
+ Stack does not stand alone. It is built on the great work provided by:
197
198
198
199
* The __ Glasgow Haskell Compiler__ ([ GHC] ( https://www.haskell.org/ghc/ ) ), the
199
200
premier Haskell compiler. Stack will manage your GHC installations and
200
- automatically select the appropriate compiler version for your project.
201
- * The __ Cabal build system__ , a specification for defining Haskell packages,
202
- 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
203
204
performing builds.
205
+
206
+ !!! info
207
+
208
+ Cabal is also the name of another build tool, provided the `cabal-install`
209
+ package. This guide distinguishes between then by Cabal (the library) and
210
+ Cabal (the tool).
211
+
204
212
* The __ Hackage Haskell Package Repository__ , a
205
- [ repository] ( https://hackage.haskell.org/ ) providing thousands of open source
206
- libraries and applications to help you get your work done.
207
- * The __ Stackage package collection__ , a
208
- [ curated set of packages] ( https://www.stackage.org/ ) from Hackage which are
209
- regularly tested for compatibility. Stack defaults to using Stackage
210
- 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.
211
220
212
221
Stack is provided by a team of volunteers and companies under the auspices of
213
222
the [ Commercial Haskell] ( http://commercialhaskell.com/ ) group. The project was
214
223
spearheaded by [ FP Complete] ( https://www.fpcomplete.com/ ) to answer the needs of
215
- 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
216
225
meeting the needs of Haskell users of all stripes.
217
226
218
227
If you'd like to get involved with Stack, check out the
@@ -236,20 +245,47 @@ The following assumes that you already have installed a version of Stack and the
236
245
[ Git application] ( https://git-scm.com/ ) .
237
246
238
247
1 . Clone the ` stack ` repository from GitHub with the command:
239
- ` git clone https://github.com/commercialhaskell/stack.git ` .
240
- 2 . Enter into the cloned ` stack ` directory with command ` cd stack ` .
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
+
241
260
3. Build the `stack` executable using a pre-existing installation of Stack with
242
- command ` stack build ` .
261
+ the command:
262
+
263
+ ~~~text
264
+ stack build
265
+ ~~~
266
+
243
267
4 . Once the ` stack ` executable has been built, check its version with the
244
- command ` stack exec -- stack --version ` . Make sure the version is the latest.
268
+ command:
269
+
270
+ ~~~ text
271
+ stack exec -- stack --version
272
+ ~~~
273
+
274
+ Make sure the version is the latest one.
275
+
245
276
5. In the GitHub respository's issue tracker, look for issues tagged with
246
277
[newcomer friendly](https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3a%22newcomer+friendly%22)
247
278
and
248
279
[awaiting pull request](https://github.com/commercialhaskell/stack/issues?q=is%3Aopen+is%3Aissue+label%3A%22awaiting+pull+request%22)
249
280
labels.
250
281
251
- If you need to check your changes quickly run ` stack ghci ` and then this command
252
- at the REPL's prompt:
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:
253
289
254
290
~~~ text
255
291
:main --stack-root=<path_to_root> --stack-yaml=<path_to_stack.yaml> <COMMAND>
0 commit comments