Module documentation for 22.214.171.124
ghc-mod: Happy Haskell Hacking
ghc-mod provides editors/IDEs with support for Haskell compiler features, it supports both Cabal and Stack based projects and integrations exist for Emacs, Vim, Atom, IntelliJ and VSCode.
- for all Haskell developers (Using ghc-mod in your development environment)
- for people developing Haskell IDEs (Using ghc-mod as an IDE backend program)
- for developing Haskell tooling (Using ghc-mod as a library)
Using ghc-mod in your Development Environment
ghc-mod in your development environment of choice you need two things:
ghc-modprogram 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
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
Internally ghc-mod uses the Glasgow Haskell Compilers's API to implement most of it's functionality.
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.
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.
ghc-mod at it's core so you'll want to be familliar with it either way.
API "documentation" is here: Hackage docs.
Please report bugs on the GitHub issue tracker for ghc-mod: https://github.com/DanielG/ghc-mod/issues
Including general environment information like the operating system
(distribution, version) you're using and the output of
$ ghc-mod debug run in
your project directory is probably a good idea.
If you have any problems, suggestions, comments swing by #ghc-mod (web client) on Freenode. If you're reporting a bug please also create an issue here (GitHub issue tracker) so we have a way to contact you if you don't have time to stay.
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.
* Fix logic bug in fix for excessive use of `map-file`
* Bump HLint to 2.x
* Reorganize Cabal file to make maintanance easier
* Merge #872, Do not log warning when Stack project is preferred
* Merge #873, Fix build on case-insensitive filesystems
* Fix 'debug' command when ghc(-pkg) not on PATH
* Rework README
* Reorganize modules as preparation for splitting off ghc-mod-core
* Remove dependency on 'pretty' and use GHC's pretty printer instead
* Merge #854, Fix for "ghc-mod doc" when usind with stack
* Merge #858, Fix Gap.fromTyThing returning GHC internal
representation instead of the user readable representation of
* Fix #774, 'find*File' searching all the way up to /
* Fix #778, Check directory permissions before reading in
* Merge #817, fix #779, bad "ghc-mod check" performance
* Bump cabal-helper to 0.7.3.0 to support Cabal-126.96.36.199
* Bump haskell-src-exts, optparse-applicative, pipes and extra
to be compatible with stackage.
* Bump cabal-helper to 0.7, adds support for Cabal-1.24
* Merge #737, `map-file` caching issues
* Merge #767, Add `browse` option to show symbol "parents"
* Merge #731, Type constraints
* Fix #69 (via #731), Missing type constraints
* Fix #438, Case splitting not working
* Fix #790, Don't try to use 'cabal' or 'stack' when it's not installed
* Add support for GHC 8.0
* Fix #660, cabal-helper errors when no global GHC is installed (Stack)
* Fix #665, Reinstate internally managed CWD (no more `ghc-mod root`
requirement for frontends)
* Merge #707, Support for spaces in file names when using
* Merge #694, #706, #703, Rewrite command line parser using
optparse-applicative. Thanks @lierdakil!
* Merge #693, Fix slowdown and bugs caused by excessive use of
* Fix #678, "No instance nor default method for class operation put"
* Fix #683, #684, a variety of caching related issues
* Fix #666, The issue of the beast >:3
* Merge #649, elisp: Add ghc-report-errors to inhibit *GHC Error*
* Fix #621, Preserve Cabal flag selection across automatic
* Add support for the Stack build tool
* Fix #554, `module not interpreted` errors when using the `type`
* 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
* 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
* Re-license majority of code under the AGPL-3
* Add support for GHC 7.10 and Cabal 1.22
* Remove `cabalDependPackages', `cabalAllTargets'
* Merge #434, Fix finding sandbox config file and directory.
* Merge #431, Re-add output line separator global option for expand
* Merge #470, Support for overriding the package-db stack
* Merge #486, Fix ineffective cache invalidation for `find`
* Merge #377, Fix `browse` erroneously thinking haskell2010 identifiers
* Fix incompatibility with monad-control >= 1.0.0
* Fix temporary directories not being removed properly
* Merge #405, #408, a race condition in the Emacs frontend
* Merge #403, Support unicode quotes in module regexp
* Fix `findCabalFiles` thinking `$HOME/.cabal` is a cabal file.
* Support `where` clauses, `let` bindings and `case` expressions
in case splitting, #400
* Fix `newTempDir` on Windows
* GhcModT's liftIO instance now converts GhcMOdError exceptions
into monadic failures
* 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 188.8.131.52 the string was "v184.108.40.206" instead of "220.127.116.11".
* Handle various consistency related issues: #222, #224, #326, #332
* Add `isOutdated` to Language.Haskell.GhcMod
* Fix building with haskell-src-exts < 1.16.0
* Fix building with haskell-src-exts-1.16.0
* Loosen monad-journal dependency
* GhcModError is now a recursive data type (`GMECabalConfigure`'s
* GhcModT's MonadIO instance now converts IOError's to failures in
the ErrorT part of GhcModT on `liftIO`.
* Make `loadSymbolDb` polimorphic in the return types's monad.
* Add `hoistGhcModT` to Language.Haskell.GhcMod.Internal
* Fix `check` command for modules using `-XPatternSynonyms`
* Merge #364, Support cabal configuration flags
* Merge #345, Try fixing duplicate errors
* Merge #344, elisp: Use advice to check syntax on save-buffer
* Merge #341, support `browse -d` in ghc-modi
* Merge #352, elisp: Fix C-u accidentally getting turned into a
* Fix CaseSplitting faliure when using "fancy types" (see #336)
* Print error information in "spec" test suite when using `extract`
* Fix missing file in "Data-Files"
* ghc-mod consumes much less memory than ghc-mod-4.1.
* @serras brought the results of Google Summer code
including case splitting and better type hole
* @DanielG provided the new monad based API
* Reverting "Trying to fix rare hang on Nix".
* Fixing the build on GHC 7.8.3.
* Trying to fix rare hang on Nix.
* Making -g-fxxx work.
* Setting Opt_WarnTypedHoles correctly.
* Making Emacs front-end more stable.
* ghc-modi now provides "type", "info", and "boot".
* ghc-mod now provides "find".
* Packages, which are specified in a cabal file but not installed,
are filtered out. (@DanielG)
* ghc-mod/ghc-modi treats "-l" properly.
* ghc-mod obsoletes "-p". Use "ghc-mod browse package:module".
* M-x ghc-debug has been implemented.
* "type" and "info" can work even if files contain type errors.
* "boot" as a new API.
* The ghc-display-error option (@notogawa)
* Fixing a file bug for Windows (@Kiripon)
* The -b option for ghc-modi (@yuga)
* Displaying a qualified name for one if two unqualified names
* 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)
* Defining ghc-debug for Elisp debugging.
* Catching up the latest hlint which does not provide --quite.
* Testing with multi GHC versions. (@eagletmt)
* Checking package ID. (@naota)
* Supporting GHC 7.8.1 RC1. (@bartavelle)
* Catching up to GHC 7.7. (@scottgw)
* Testing with multi GHC versions. (@eagletmt)
* Workaround for the coming new Haskell Platform.
* Supporting flymake of the coming Emacs 24.4.
* GHCi loading as fallback for browse. (@khorser)
* Supporting GHC 7.7. (@schell)
* Introducing the "-p" and "-q" option for browse. (@mvoidex)
* Fixing tests. (@eagletmt)
* Supporting sandbox for "list" and "browse". (@eagletmt)
* Making Cradle strict.
* API breaks backward compatibility.
* Supporting sandbox sharing.
* Fixing a bug of "dist/build/autogen/cabal_macros.h".
* Exporting more low level APIs.
* Adding "-ibuild/autogen"
* Adding "-optP". (Macros from a Cabal file
* Supporting the sandbox of cabal 1.18.
* Obsoleting the support for cabal-dev.
* Supporting multiple target files. (@nh2)
* A bug fix for library dependency.
* Exporting Language.Haskell.GhcMod.Internal. (@alanz)
* Supporting GHC 7.7. (@co-dan)
* Using finalizePackageDescription to enable "if else" in a cabal
* Document fixes.
* Document fixes.
* ghc-mod also provides a library (Language.Haskell.GhcMod)
* A bug fix for the case where a cabal file is broken.
* C-M-d on Emacs now can browse functions and types.
* Checking "QuasiQuotes" as well as "TemplateHaskell". (@eagletmt)
* "ghc-mod info" can display info of non-exported functions.
* "ghc-mod info" and "ghc-mod type" also check Template Haskell.
* New logic to set "-fno-code" using "depanal"
* Cleaning up the code relating to Doc/SDoc
* Fixing a bug to find a sandbox.
* "ghc-mod debug" to see which cabal file and sand box are used
* Fast "ghc-mod check" if Template Haskell is not used
* "ghc-mod brwose -d" displays more information (@eagletmt)
* New option "-d" for "ghc-mod browse" to show symbols with type
* Adding Hspec test suite
* Better way to show Extension (@eagletmt)
* Removing the library itself from Cabal dependencies
* Display a filname instead of "Dummy" if an error occur
* Extract dependencies from a Cabal file if exists and specify
them to "ghc-mod check" (@khibino)
* Supporting GHC 7.6.x (@cartazio, @dysinger, @ihameed)