Skip to main content

Install Haskell

This is a guide to installing Haskell using Stack.

Install Stack

Stack is a tool for managing haskell projects, installing compilers and packages, and building projects. The installation is done as follows.

sudo pacman -S stack

Basic Usage

To create a new project, run stack new.

stack new hs-proj

When you create a new project, the following directory structure will be created, and you can write the main code in Main.hs.

.
├── app
│ └── Main.hs
├── ChangeLog.md
├── LICENSE
├── package.yaml
├── proj-name.cabal
├── README.md
├── Setup.hs
├── src
│ └── Lib.hs
├── stack.yaml
├── stack.yaml.lock
└── test
└── Spec.hs

To compile, run stack build.

stack build

To execute code, run stack exec *-exe.

stack exec hs-proj-exe

Remove stack

Remove ~/.stack and /usr/local/bin/stack.

Reference