stack
is a cross-platform program for developing Haskell
projects. It is aimed at Haskellers both new and experienced.
It features:
- Installing GHC automatically, in an isolated location.
- Installing packages needed for your project.
- Building your project.
- Testing your project.
- Benchmarking your project.
Downloads are available by operating system:
Note: if you are using cabal-install to install stack, you may need to pass a
constraint to work around a
Cabal issue: cabal install --constraint 'mono-traversable >= 0.9' stack
.
First you need to install it (see previous section).
stack new my-project
cd my-project
stack setup
stack build
stack exec my-project-exe
- The
stack new
command will create a new directory containing all the needed files to start a project correctly. - The
stack setup
will 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 thestack path
command.). - The
stack build
command will build the minimal project. stack exec my-project-exe
will execute the command.- If you just want to install an executable using stack, then all you have to do
is
stack install <package-name>
.
If you want to launch a REPL:
stack ghci
Run stack
for a complete list of commands.
The 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
src/
directory.
The app
directory should preferably contains only files related to
executables.
-
If you need to include another library (for example the package
text
:- Add the package
text
to the filemy-project.cabal
in the sectionbuild-depends: ...
. - run
stack build
another time
- Add the package
-
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.yaml
file in theextra-deps
section.
It was a really fast introduction on how to start to code in Haskell using stack
.
If you want to go further, we highly recommend you to read the stack
guide.
This assumes that you have already installed a version of stack, and have git
installed.
- Clone
stack
from git withgit clone https://github.com/commercialhaskell/stack.git
. - Enter into the stack folder with
cd stack
. - Build
stack
using a pre-existingstack
install withstack setup && stack build
. - Once
stack
finishes building, check the stack version withstack --version
. Make sure the version is the latest. - Look for issues tagged with
newcomer
andawaiting-pr
labels
Build from source as a one-liner:
git clone https://github.com/commercialhaskell/stack.git && \
cd stack && \
stack setup && \
stack build
This repository also contains a complete user guide to using stack , covering all of the most common use cases.
- 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.
- Project Documentation
- Maintainer Guide: includes releasing information
- Signing Key: downloadable stack binaries are signed with this key
- Tool Documentation
- Build Command: reference for the syntax of the build command and the command line targets
- Dependency Visualization: uses Graphviz
- Docker Integration
- FAQ: frequently asked questions about detailed or specific use-cases
- Install/Upgrade: a list of downloads available by operating system, installation instructions, and upgrade instructions
- Nonstandard Project Initialization
- Shell Autocompletion
- User Guide: in-depth tutorial covering the most common use cases and all major stack features (requires no prior Haskell tooling experience)
- YAML Configuration: reference for writing
stack.yaml
files
- Advanced Documentation
- Architecture: reference for people curious about stack internals, wanting to get involved deeply in the codebase, or wanting to use stack in unusual ways