MyNixOS website logo
Description

Happy Haskell Hacking.

ghc-mod is a backend program to enrich Haskell programming in editors. It strives to offer most of the features one has come to expect from modern IDEs in any editor. ghc-mod provides a library for other haskell programs to use as well as a standalone program for easy editor integration. All of the fundamental functionality of the frontend program can be accessed through the library however many implementation details are hidden and if you want to significantly extend ghc-mod you should submit these changes upstream instead of implementing them on top of the library.

ghc-mod: Happy Haskell Hacking

build status

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.

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

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.

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.

API "documentation" is here: Hackage docs.

Reporting Bugs

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.

IRC

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.

Metadata

Version

5.8.0.0

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows