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)

    1. Install Nix: curl https://nixos.org/nix/install | sh && . $HOME/.nix-profile/etc/profile.d/nix.sh
    2. Install Stack: nix-env -i stack
  • Windows (NB. sometimes Stack fails when installing packages on Windows, just re-run it - see issue for details)

    1. Install Scoop: (in PowerShell) iex (new-object net.webclient).downloadstring('https://get.scoop.sh')
    2. Install Stack: scoop install stack
    3. Add %USERPROFILE%\AppData\Roaming\local\bin to your system PATH environment variable (NB. in Win10 hit windows key then type Edit environment variables for your account)

Then, get set up:

  1. Make absolutely sure stack is up to date: stack update
  2. Setup Haskell: stack setup (this takes a while, so go and make some coffee!)
  3. Validate that GHCi works: stack ghci, then :quit to leave

Quick-start

  1. Install VSCode (available in scoop if you scoop bucket add extras then scoop install vscode, and available in nix nix-channel --update && nix-env -i vscode)
  2. Install dependencies: stack install intero hoogle hlint hspec stylish-haskell and hoogle generate
  3. Install VSCode Haskero and haskell-linter plugins
  4. Create a new Stack project somewhere: stack new ProjectName
  5. Open up the ProjectName dir in VSCode
  6. 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 or hsdev (both backends, so you likely only need one of these, prefer ghc-mod)
  • hlint
  • hindent
  • stylish-haskell
  • hoogle

Then, based on the editor you want to use, do the following:

  • Atom:
    1. Install plugins:
      • language-haskell
      • haskell-ghc-mod
      • ide-haskell
      • autocomplete-haskell
    2. Add to keybindings:
      'atom-text-editor[data-grammar~="haskell"]':
        'f12': 'haskell-ghc-mod:go-to-declaration'
      
  • VSCode: follow quick start instructions above, for debugging support search for Phoityne and install that
  • Sublime:
    1. Install dependencies: stack install hsdev
    2. Install Package Control via instructions on https://packagecontrol.io/
    3. Install plugin SublimeHaskell
  • IntelliJ:
    1. Install dependencies: stack install stylish-haskell hlint ghc-mod hindent
    2. Install plugin HaskForce
    3. Set Settings -> Build, Execution, Deployment -> Haskell Compiler to Build with Stack
    4. Configure in Settings -> Other Settings -> Haskell Tools - just use Auto Find on each

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.