Do not ever install the Haskell Platform!
Install the Haskell language compiler, REPL, and build tool using Stack.
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/ | shwget -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-namewhereproject-nameis whatever you want to call your projectcd project-nameto switch to the new directory that Stack will have created for your projectstack buildto compile the projectstack exec project-name-exeto run the compiled output
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 LTSstack config set resolver lts-11.3will set Stack to use a specific LTSstack 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.3resolver: lts-9.5for GHC 8.0.2resolver: lts-11.3for GHC 8.2.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"