Happy Haskell programming on Emacs/Vim
"ghc-mod" is a command to enrich Haskell programming on editors including Emacs and Vim. The ghc-mod package includes the "ghc-mod" command and Emacs front-end.
Emacs front-end is an extension of Haskell mode. They enable to complete Haskell symbols on Emacs and to browse documents of modules. Flymake with GHC/Hlint is also integrated.
Vim plugin is also available from github.
The current package can be found in Hackage. The git repository is on github.
Usage for Emacs
- M-C-i
- Completes a name of keyword, module, class, function, types, language extensions, GHC flags, etc.
- M-/
- Completes a name of local symbol.
- M-t
- Inserts template. In the beginning of a buffer, "module Foo where" is inserted. On the function without signature, inferred type is inserted. On a symbol "foo" without definition, "foo = undefined" is inserted. Original code is replaced with hlint's suggestion if possible.
- M-C-d
- Browses the local document of the module on the current line (e.g. the import line) on your browser
- C-uM-C-d
- Browses the Hackage document of the module on the current line (e.g. the import line) on your browser
- M-C-m
- Loads information of symbols for modules in the current buffer. If you add a new line to import a module, type this. The idle timer executes this command anyway.
- C-xC-s
- Saves the buffer if necessary and runs syntax check. Also, a timer executes syntax check automatically.
- C-cC-c
- Toggle GHC and Hlint for syntax check. GHC is used for initial time.
- M-n
- Goes to the next warning or error.
- M-p
- Goes to the previous warning or error.
- M-?
- Displays the warning/error message in the current line.
- C-cC-i
- Displays the info of this expression in another window.
- C-cC-t
- Displays the type of this expression in the minibuffer. Type C-cC-t multiple time to enlarge the expression.
- C-cC-m
- Insert "import Module" for this function. "hoogle" command is required and "hoogle data" should be done beforehand.
Customizing
If you want to specify GHC options from Emacs, set "ghc-ghc-options". The following is an example to specify the "-i" options to GHC.
(setq ghc-ghc-options '("-idir1" "-idir2"))