Getting up and running with Haskell - ahri/lazymanc.net GitHub Wiki
Do not install the "Haskell Platform" - it is outdated and not at all a helpful start
First, install Stack:
-
Linux/MacOS (it is available from apt/brew/etc. if you prefer, but these are sometimes very old)
- Install Nix:
curl https://nixos.org/nix/install | sh && . $HOME/.nix-profile/etc/profile.d/nix.sh
- Install Stack:
nix-env -i stack
- Install Nix:
-
Windows (NB. sometimes Stack fails when installing packages on Windows, just re-run it - see issue for details)
- Install Scoop: (in PowerShell)
iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
- Install Stack:
scoop install stack
- Add
%USERPROFILE%\AppData\Roaming\local\bin
to your systemPATH
environment variable (NB. in Win10 hit windows key then typeEdit environment variables for your account
)
- Install Scoop: (in PowerShell)
Then, get set up:
- Make absolutely sure stack is up to date:
stack update
- Setup Haskell:
stack setup
(this takes a while, so go and make some coffee!) - Validate that GHCi works:
stack ghci
, then:quit
to leave
Quick-start
- Install VSCode (available in scoop if you
scoop bucket add extras
thenscoop install vscode
, and available in nixnix-channel --update && nix-env -i vscode
) - Install dependencies:
stack install intero hoogle hlint hspec stylish-haskell
andhoogle generate
- Install VSCode
Haskero
andhaskell-linter
plugins - Create a new Stack project somewhere:
stack new ProjectName
- Open up the
ProjectName
dir in VSCode - Note that you can use the Terminal within VSCode to run
stack ghci
General editor support
A more complete comparison is available.
Editors may need dependencies, so install via stack install PACKAGE
where package might be one or more of:
ghc-mod
orhsdev
(both backends, so you likely only need one of these, preferghc-mod
)hlint
hindent
stylish-haskell
hoogle
Then, based on the editor you want to use, do the following:
- Atom:
- Install plugins:
language-haskell
haskell-ghc-mod
ide-haskell
autocomplete-haskell
- Add to keybindings:
'atom-text-editor[data-grammar~="haskell"]': 'f12': 'haskell-ghc-mod:go-to-declaration'
- Install plugins:
- VSCode: follow quick start instructions above, for debugging support search for
Phoityne
and install that - Sublime:
- Install dependencies:
stack install hsdev
- Install Package Control via instructions on https://packagecontrol.io/
- Install plugin
SublimeHaskell
- Install dependencies:
- IntelliJ:
- Install dependencies:
stack install stylish-haskell hlint ghc-mod hindent
- Install plugin
HaskForce
- Set
Settings -> Build, Execution, Deployment -> Haskell Compiler
toBuild with Stack
- Configure in
Settings -> Other Settings -> Haskell Tools
- just useAuto Find
on each
- Install dependencies:
IHaskell
Yet another option is using Jupyter notebooks using the IHaskell kernel. You can take notes along Haskell scripts like in this demo notebook. You can find installation instructions here.