Haskell Stack Notes
Visit the Get Started page on haskell-lang.org or read the Stack documentation for the most up-to-date instructions for installing Haskell using the Stack platform. Avoid using other installation solutions, including any variant of the Haskell Platform.
On other Unix and Unix-like systems, you can generally install directly by using one of the following commands:
curl -sSL https://get.haskellstack.org/ | sh
wget -qO- https://get.haskellstack.org/ | sh
For Mac OS X users who have Homebrew:
brew install haskell-stack
Note that the Homebrew installation could be out of date at times, so the curl method is preferred.
Windows users should download the 64-bit installer directly from Stackage.
Setting up a project
For basic experimentation and doing exercises, it is recommended that you just create a directory for your code files and use the global Stack installation, which will run automatically when you type
stack ghc for the compiler or
stack ghci for the REPL.
To set up a full project, enter the following commands:
stack new project-namewhere
project-nameis whatever you want to call your project
cd project-nameto switch to the new directory that Stack will have created for your project
stack setupto create a basic project framework
stack buildto compile the project
stack exec project-name-exeto run the compiled output
Upgrading Stack or GHC
stack updatewill update your packages, but you don't generally need to do this manually.
stack upgradewill reinstall Stack from source, including GHC.
stack config set resolver ltswill update Stack (globally or locally within a project) to the latest LTS
stack config set resolver lts-9.3will set Stack to use a specific LTS
stack exec -- ghc --versionwill tell you what version of GHC you are using.
If you want to use a specific version of GHC for your global Stack installation, edit your
~/.stack/global-project/stack.yaml file, and set the resolver to whichever version prefer, for example:
resolver: lts-6.11for GHC 7.10.3
resolver: lts-7.16for GHC 8.0.1
resolver: lts-9.3for GHC 8.0.2
For project-specific installations of Stack, edit your project's local
stack.yaml file instead.
Add the following line(s) to your shell's configuration dotfile (e.g.
.zshrc) to enable support for shell tab completion for standard Stack arguments.
eval "$(stack --bash-completion-script stack)"
autoload -U +X compinit && compinit autoload -U +X bashcompinit && bashcompinit eval "$(stack --bash-completion-script stack)"
stack ghc or
stack ghci is annoying you, add the following aliases to your shell dotfile:
alias ghci="stack exec -- ghci" alias ghc="stack exec -- ghc"