Haskell Intero in Emacs: first impressions and HOWTO

Intero is a new/enhanced Stack-integrated REPL for Haskell like GHCi. It includes an Emacs mode that integrates with Stack as well.

First of all, major thanks to Chris Done and the other contributors for putting this together.


Okay, my first impression of Intero is positive with some reservations.

The bad, it is super slow the first time in a project and blocks the entire Emacs process (not cool).  The really good, it loads very very fast on subsequent modules in the same project and in subsequent Emacs sessions.

Jump to definition (M-.) works well.  It silently fails to cross dependency boundaries.  That may be able to be worked around and would be tricky.  Stack may want to add a feature for downloading build-depends sources like SBT does for Scala.  Then again maybe I should be looking at type signatures and not source of libraries :)

Type of selection (C-c C-t) is accurate and fast. On modules that no longer compile it often works, but is incomplete. If the compile breakage adds lines Intero can't follow them and sometimes says "<interactive>:1:1: Not in scope: 'symbolUnderCursor'" and sometimes returns bogus type info like "symbolUnderCursor :: IO ()".




Wait, wait, wait! How do I set this up you say.






HOWTO: Installing intero-mode in Emacs

Install intero-mode

If you don't already have a working Haskell environment in Emacs please jump to the Pre-Requisites (Yak shaving) section below before continuing.

git clone https://github.com/commercialhaskell/intero

M-x load-file and select intero/elisp/intero.el (wherever you cloned it to).

In a Haskell module in a Stack-enabled project (stack new intero-demo if you haven't got one on hand) run M-x intero-mode to try it out.

Hit C-c C-l to launch an intero session for the current project.

From here on you have the ability to run the Type of selection (C-c C-t) and Jump to definition (M-.) described above.

Pre-Requisites (Yak shaving)

BACK UP your Emacs config (~/.emacs and ~/.emacs.d at minimum before doing this)!

Make sure Stack is installed and symlinked to /usr/bin or somewhere else in your Emacs path.

You can satisfy Emacs pre-reqs by:

  1. Installing Emacs Prelude (self-shaving Yak)
  2. Installing Chris Allen's Emacs dotfiles (quick brush cut)
  3. Using ELPA to install dependencies of intero (full on hand scissors exercise)

Satisfy pre-reqs with Emacs Prelude

Follow instruction on http://batsov.com/prelude/

Satisfy pre-reqs with Chris Allen's Emacs dotfile

git clone https://github.com/bitemyapp/dotfiles

cp -R dotfiles/.emacs dotfiles/.emacs.d/ ~

This is probably incomplete, but it worked for me.  I am using Chris Allen's Emacs configuration though so YMMV.  I suspect it depends on haskell-mode.

Satisfy pre-reqs using MELPA

If you get here and you are not Emacs-familiar I strongly recommend watching jekor's .Emacs Tutorials series on YouTube:


Launch Emacs (M-x means hold meta key and hit x, meta is usually Alt on Windows/GNOME or Option on OS X)

M-x customize

In the input box enter "exec-path" and click Search

Expand Package Archives

Click INS above State

Click Value Menu and select Directory

In the textbox type "/usr/local/bin" or whatever directory you have stack in (try which stack in Bash to find that)

M-x customize

In the input box enter "package archives" and click Search

Expand Package Archives

Click INS above State

Enter "melpa" for Archive name and "https://melpa.org/packages/" for URL or directory name.

Click Apply and Save.

M-x list-packages

C-s to bring up I-search

Enter flycheck and hit Enter

Hit i to mark flycheck for installation

Hit Esc < to go to the top of the package list


Enter "  company 2016" (really space space at the beginning as there are eleventy-billion company-related things in the package list) and hit Enter.

Hit i to mark company for installation

Hit Esc < to go to the top of the package list


Enter "  haskell-mode 2016" and hit Enter.

Hit i to mark haskell-mode for installation

Hit x to accept selection and type yes and hit Enter to begin installation