Intero for Emacs

Intero for Emacs

Complete interactive development program for Haskell

“I just tried this and it works. It just works. I have never had this experience with Haskell + Emacs. Thank you so much for this.”

Install package

Use Emacs's built in package manager. Add the following to your .emacs:

;; If you don't have MELPA in your package archives:
(require 'package)
(add-to-list
  'package-archives
  '("melpa" . "http://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)

;; Install Intero
(package-install 'intero)
(add-hook 'haskell-mode-hook 'intero-mode)

Modern and backwards compatible

CI tested on GHC 8.6.3, 8.4.4, 8.2.2, 8.0.2, 8.0.1, 7.10.3, 7.10.2, and 7.8.4.

Backwards compatibility will be maintained as far back as is possible.

General backend

The Intero backend used by the Emacs mode is a fork of GHCi, it behaves like your old friend GHCi, but with more features.

Support for other editors is not promised, but patches are welcome.

Designed for Stack

Intero requires stack. Tested on a variety of Hackage projects, internal client projects, from small to huge.

If your project works with Stack, it almost definitely works with Intero.

Automatically installing

The Emacs mode automatically installs the proper Intero backend program in your stack environment. Not globally!

Each Stack project can have a separate GHC or LTS version, Intero takes care of this by installing a fresh copy in each LTS version.

After installing, it automatically boots up Intero and starts checking the current file.

On the fly type checking

Intero works with and configures the marvelous Flycheck package out of the box. Giving check as-you-type, on a keybinding of your change, and/or on save.

Errors can be seen by going to the location of the error, or by hitting C-c ! l to see a list of errors.

One can also jump to errors: C-c ! n for next error, C-c ! p for previous error.

Easy target switching

Working on the test suite now? Just hit M-x intero-targets and enter a stack target.

In the example on the right, the target is weigh:test:weigh-test, but we can write :weigh-test for short because it's unambiguous.

Intero restarts with those targets configured, and re-runs the flychecker. Everything is now good to go!

There will be interactive completion for targets in the future.

Completion as you type

Intero works with the Company package out of the box. Auto-complete as-you-type is based on identifiers that are locally defined in the declaration, in the module, or imported within the module.

Continues to remember its completions through type errors. In the future, completion will be type-driven.

Jump to definition

After a module has been type checked, you can jump to the definition of any locally defined or imported identifier.

Uses the standard Emacs keybinding for jumping, M-.. Remembers locations even when a module no longer compiles.

Type of selection

You can hit C-c C-t to display the type of the identifier at point, or select any text to see the type.

Remembers type information even when a module no longer compiles.

Applying suggestions

You can run C-c C-r to automatically apply suggestions given by GHC.

Supported suggestion types:

  • Extensions
  • Add names to explicit import lists
  • Remove redundant imports
  • Add missing type-signatures
  • Fix typos

Next steps

What are you waiting for? Give it a try.

↑ Install now