:lang haskell

A language that’s lazier than I am

1. Description

This module adds Haskell support, powered by either dante (the default) or LSP (haskell-language-server or ghcide).

  • Code completion (company-ghc)
  • Look up documentation (hoogle)
  • eldoc support (dante)
  • REPL (ghci)
  • Syntax-checking (flycheck)
  • Code navigation (dante)
  • Snippets

1.1. Module flags

+dante
Enables dante; a fork of intero aimed at lightweightedness. It doesn’t depend on stack, supports both cabal-only and stack projects, but lacks eldoc support.
+ghcide
Enables LSP support for haskell-mode utilizing ghcide. Requires :tools lsp.
+lsp
Enables LSP support for haskell-mode utilizing haskell-language-server. Requires :tools lsp.

2. Prerequisites

Depending on whether you use Dante, haskell-language-server or ghcide, your dependencies will differ:

  • Dante users need cabal, ghc and ghc-mod
  • LSP users need the haskell-language-server LSP server OR ghcide
  • All users will need the hoogle package

2.1. Cabal

To use Dante, you need cabal (the haskell package builder) and ghci (the compiler, syntax checker & repl):

2.1.1. MacOS

$ brew install cabal-install ghc

2.1.2. Arch Linux

$ pacman -S cabal-install ghc

2.1.3. openSUSE

$ zypper install cabal-install ghc

2.2. LSP (haskell-language-server)

You will need stack and git installed.

You will find a comprehensive instructions for haskell-language-server on its project page, but if you are using ghcup:

$ ghcup install hls

2.3. LSP (ghcide)

See https://github.com/digital-asset/ghcide for install instructions.

2.4. Stack

To use LSP, you need stack:

2.4.1. MacOS

$ brew install haskell-stack
$ stack setup

2.4.2. Arch Linux

$ sudo pacman -S stack
# Replace pacaur with your AUR package manager of choice
$ pacaur -S ncurses5-compat-lib
$ stack setup

2.4.3. openSUSE

$ zypper install stack
$ stack setup

2.5. Haskell packages

You’ll need to install the following packages using stack or cabal:

  • (Dante users) ghc-mod

    $ stack install ghc-mod
    # or
    $ cabal install ghc-mod
    
  • hoogle

    $ cabal update
    $ cabal install happy haskell-src-exts   # ghc-mod/hoogle dependencies
    $ cabal ghc-mod hoogle
    # or
    $ stack install ghc-mod
    $ stack install hoogle
    

And ensure the binaries for these packages are in your PATH, e.g.

# place this in your profile file, like ~/.bash_profile or ~/.zshenv
export PATH="~/.local/bin:$PATH"

3. TODO Usage

This module has no usage documentation yet. Write some?

4. Configuration

4.1. Using the new-style cabal REPL

haskell-mode will typically detect what REPL to run based on your project (e.g. stack, (old-style) cabal or ghc). If you want the new-style cabal REPL you must set haskell-process-type manually:

(setq haskell-process-type 'cabal-new-repl)

5. Troubleshooting

6. TODO Appendix

This module’s appendix is incomplete. Write more?

6.1. External resources

Here are a few resources I’ve found indispensable in my Haskell adventures: