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.
If you accidentally installed the Haskell Platform or have an old installation haunting your machine, you can try following these instructions or using this code to cleanse your system.
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-name
whereproject-name
is whatever you want to call your projectcd project-name
to switch to the new directory that Stack will have created for your projectstack setup
to create a basic project frameworkstack build
to compile the projectstack exec project-name-exe
to run the compiled output
stack update
will update your packages, but you don't generally need to do this manually.stack upgrade
will reinstall Stack from source, including GHC.stack config set resolver lts
will update Stack (globally or locally within a project) to the latest LTSstack config set resolver lts-9.3
will set Stack to use a specific LTSstack exec -- ghc --version
will 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.11
for GHC 7.10.3resolver: lts-7.16
for GHC 8.0.1resolver: lts-9.3
for 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. .bash_profile
or .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)"
If typing 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"