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.

Mini-Review

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:

Installing Emacs Prelude (self-shaving Yak)

Installing Chris Allen's Emacs dotfiles (quick brush cut)

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: