Overview

Using ghc-mod in your Development Environment

To use ghc-mod in your development environment of choice you need two things:

The ghc-mod program included in the package of the same name, see Installing

A ghc-mod frontend to integrate it into your development environment, see Frontend

Using ghc-mod as an IDE Backend Program

We provide two modes of operation for frontends: interactive and single shot
mode. The former is accessed by calling $ ghc-mod legacy-interactive this will
sit and wait for you to type a command and exit when an empty line is
entered. Interactive mode is pretty much always faster than single shot mode
since it gives ghc-mod the ability to cache the compiler session between
commands on the other hand it needs more memory because it keeps these things
cached.

Single shot mode is pretty much only there for (backwards) compatibility with
Vim since it only recently got the ability to talk to background processes
without installing some external plugin. You can use single-shot mode by simply
calling the sub-comamnds of the ghc-mod program. Since re-compiling large
projects can be really, really slow you really shouldn't use this and use
interactive mode instead.

As a rule of thumb all commands available in single shot mode are available in
interactive mode, a list of the former can be obtained by running
$ ghc-mod --help.

If you're developing a new ghc-mod fronted we'd love to hear from you! Please
open an issue or e-mail the maintainer. Also we invite you to add installation
and configuration instructions to
Frontend.

Using ghc-mod as a Library

In order to provide a hassle free experience to users ghc-mod tries hard to
automatically, and correctly, detect and if needed tweak the environment GHC
needs. It also handles some of the more cumbersome parts of getting a working
compiler session up and running.

This functionality can be very useful to all kinds of Haskell development tools
therefore want to expose all the useful abstractions ghc-mod provides.

Right now the ghc-mod API is pretty messy; a result of major internal rewrites
and reorganization coupled with too little time for cleanups over the course of
almost 100 releases! We would like to make a cut during v6.0 or so and
completely re-do the API but we need more input from downstream tool writers to
do that properly, see Library API Redesign.

For example The Haskell Refactorer (HaRe) uses
the build environment abstraction ghc-mod provides so it can concentrate on it's
core functionality instead of worrying about build environments and compiler
session setup.

Recently the
haskell-ide-engine project
has sprung up and if you're planning to write any kind of tool that needs editor
integration eventually you should definetly look into that. haskell-ide-engine
uses ghc-mod at it's core so you'll want to be familliar with it either way.

Do hang around for a while if no one answers and repeat your question if you
still haven't gotten any answer after a day or so (the maintainer was probably
asleep). You're most likely to get an answer during the day in GMT+1.

2015-09-16 v5.4.0.0 * Add support for the Stack build tool * Fix #554, `module not interpreted` errors when using the `type` command * Merge #484, support for file redirection * Add support for file redirection to Emacs frontend so all commands should work even with unsaved files now! * Support inserting holes in type signatures * Merge #543, Fix URL anchors being dropped in OS X * Fix GHC session always being dropped in interactive mode (caused super slowness) * Expose all internal modules because API will get a major redesign soon anyways * ghc-mod(i) executable must now be run in project directory for commands other than `root` * Add --line-prefix option for multiplexing stdout/err onto one stream

2014-10-30 v5.2.0.0 * Return type of `loadSymbolDb` is now in GhcModT * Function `dumpSymbol` now takes the path of the target directory * Fix #387, Pattern match failure in GhcPkg * Fix #386, `ghc-mod version` should not check `cabal configure` * Fix #391, Error on command `-g` when used before command despite --help output saying this is valid * Fix formatting of `ghc-version` constant in the elisp code. in version 5.1.1.0 the string was "v5.1.1.0" instead of "5.1.1.0".

2014-04-03 v4.0.1 * Displaying a qualified name for one if two unqualified names are conflict.

2014-04-01 v4.0.0 * Implementing interactive "ghc-modi" command. "check", "find", and "lint" are available. * Introducing a concept of project root directory. Thanks to this, sandbox without cabal can be used. "ghd-mod debug" displays the project root. * Syntax error highlighting (C-xC-s) gets much faster thanks to ghc-modi. "flymake" was thrown away and syntax error highlighting is implemented from a scratch. * Resolving the "import hell". You dont' have to type "import Foo" anymore. Use M-t or C-cC-m. * Inserting "module Foo" (M-t) can insert all paths relative to the project root. * M-C-d displays a html document even if it is in its sandbox. * M-s now merges the same module lines in addition to sorting. * A bug fix for hlint support. (@eagletmt)

2014-03-15 v3.1.7 * Defining ghc-debug for Elisp debugging. * Catching up the latest hlint which does not provide --quite.