22
33# The Haskell Tool Stack
44
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.
89
910<img src =" https://i.imgur.com/WW69oTj.gif " width =" 50% " align =" right " >
1011
@@ -19,35 +20,47 @@ Stack features:
1920
2021## How to install Stack
2122
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
2324on Windows.
2425
25- For most Unix-like operating systems, the easiest way to install Stack is to
26- command:
26+ === "Unix-like"
2727
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:
3130
32- or:
31+ ~~~text
32+ curl -sSL https://get.haskellstack.org/ | sh
33+ ~~~
3334
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).
3754
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
4256
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 .
4559
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).
5164
5265## How to upgrade Stack
5366
@@ -63,7 +76,7 @@ stack upgrade
6376For an immediate experience of using Stack to build an executable with Haskell,
6477first you need to follow the [ guide to install Stack] ( #how-to-install-Stack ) .
6578
66- ### Start your new project
79+ ### Step 1: Start your new project
6780
6881To start a new project named ` my-project ` , issue these four commands in a
6982terminal:
@@ -76,13 +89,14 @@ stack exec my-project-exe
7689~~~
7790
7891- 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,
8093 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.
8296- 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 .
86100- The ` stack exec my-project-exe ` command will run (execute) the built
87101 executable, in Stack's environment.
88102
@@ -98,23 +112,27 @@ For help on a particular Stack command, for example `stack build`, command:
98112stack build --help
99113~~~
100114
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:
102116
103117~~~ text
104- stack ghci
118+ stack repl
105119~~~
106120
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:
109127
110128~~~ text
111129stack install <package-name>
112130~~~
113131
114- ### Workflow
132+ ### Step 2: Next steps
115133
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) :
118136
119137~~~ text
120138.
@@ -124,47 +142,43 @@ and directories:
124142│ └── Lib.hs
125143├── test
126144│ └── Spec.hs
127- ├── Setup.hs
128- ├── package.yaml
129145├── my-project.cabal
130- ├── stack.yaml
131- ├── README.md
132- ├── ChangeLog.md
133- ├── LICENSE
134- └── .gitignore
146+ ├── package.yaml
147+ └── stack.yaml
135148~~~
136149
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 ` .
138153
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 ` .
143156
144- To manage your library:
157+ !!! info
145158
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 .
148161
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)) .
151164
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.
156168
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
159170
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.
164178
165179That was a really fast introduction on how to start to code in Haskell using
166180Stack. 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 ) .
168182
169183## Complete guide to Stack
170184
@@ -174,32 +188,40 @@ explained in the [glossary](glossary.md).
174188
175189## Why Stack?
176190
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.
181196
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:
184198
185199* The __ Glasgow Haskell Compiler__ ([ GHC] ( https://www.haskell.org/ghc/ ) ), the
186200 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
190204 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+
191212* 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.
198220
199221Stack is provided by a team of volunteers and companies under the auspices of
200222the [ Commercial Haskell] ( http://commercialhaskell.com/ ) group. The project was
201223spearheaded 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
203225meeting the needs of Haskell users of all stripes.
204226
205227If you'd like to get involved with Stack, check out the
@@ -222,21 +244,48 @@ label on the GitHub issue tracker.
222244The following assumes that you already have installed a version of Stack and the
223245[ Git application] ( https://git-scm.com/ ) .
224246
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:
240289
241290~~~ text
242291:main --stack-root=<path_to_root> --stack-yaml=<path_to_stack.yaml> <COMMAND>
0 commit comments