The Haskell Tool Stack¶
Stack is a cross-platform program for developing Haskell projects. It is aimed at Haskellers both new and experienced.
- Installing GHC automatically, in an isolated location.
- Installing packages needed for your project.
- Building your project.
- Testing your project.
- Benchmarking your project.
How to install¶
For many Un*x operating systems, all you need to do is run:
curl -sSL https://get.haskellstack.org/ | sh
wget -qO- https://get.haskellstack.org/ | sh
For detailed instructions and downloads, instructions are available by operating system/distribution:
- CentOS / Red Hat / Amazon Linux
- openSUSE / SUSE Linux Enterprise
- Arch Linux
- Linux (general)
Quick Start Guide¶
First you need to install it (see previous section).
Start your new project:¶
stack new my-project cd my-project stack setup stack build stack exec my-project-exe
stack newcommand will create a new directory containing all the needed files to start a project correctly.
stack setupwill download the compiler if necessary in an isolated location (default
~/.stack) that won't interfere with any system-level installations. (For information on installation paths, please use the
stack buildcommand will build the minimal project.
stack exec my-project-exewill execute the command.
- If you just want to install an executable using stack, then all you have to do
stack install <package-name>.
If you want to launch a REPL:
stack for a complete list of commands.
stack new command should have created the following files:
. ├── LICENSE ├── Setup.hs ├── app │ └── Main.hs ├── my-project.cabal ├── src │ └── Lib.hs ├── stack.yaml └── test └── Spec.hs 3 directories, 7 files
So to manage your library:
- Edit files in the
app directory should preferably contain only files related to
If you need to include another library (for example the package
Add the package
textto the file
my-project.cabalin the section
stack buildanother time
If you get an error that tells you your package isn't in the LTS. Just try to add a new version in the
stack.yamlfile in the
It was a really fast introduction on how to start to code in Haskell using
If you want to go further, we highly recommend you to read the
How to contribute¶
This assumes that you have already installed a version of stack, and have
stackfrom git with
git clone https://github.com/commercialhaskell/stack.git.
- Enter into the stack folder with
stackusing a pre-existing
stack setup && stack build.
stackfinishes building, check the stack version with
stack exec stack -- --version. Make sure the version is the latest.
- Look for issues tagged with
Build from source as a one-liner:
git clone https://github.com/commercialhaskell/stack.git && \ cd stack && \ stack setup && \ stack build
Complete guide to stack¶
This repository also contains a complete user guide to using stack , covering all of the most common use cases.
Questions, Feedback, Discussion¶
- For frequently asked questions about detailed or specific use-cases, please see the FAQ.
- For general questions, comments, feedback and support please write to the stack mailing list.
- For bugs, issues, or requests please open an issue.
- When using Stack Overflow, please use the haskell-stack tag.
stack is a project of the Commercial Haskell group, spearheaded by FP Complete. It is designed to answer the needs of commercial Haskell users, hobbyist Haskellers, and individuals and companies thinking about starting to use Haskell. It is intended to be easy to use for newcomers, while providing the customizability and power experienced developers need.
While stack itself has been around since June of 2015, it is based on codebases used by FP Complete for its corporate customers and internally for years prior. stack is a refresh of that codebase combined with other open source efforts like stackage-cli to meet the needs of users everywhere.
A large impetus for the work on stack was a large survey of people interested in Haskell, which rated build issues as a major concern. The stack team hopes that stack can address these concerns.