Haskell Mode as one of its components provides a major mode for editing
Haskell source code called
haskell-mode, which gave the name to
the whole project. There is a derived mode provided called
literate-haskell-mode that support Literate Haskell source code
both in Bird and in Latex forms.
Haskell Mode supports files with the following extensions:
official file extension for Haskell files. Haskell Mode out of the box supports most of GHC extensions.
official file extension for Literate Haskell files. Both Bird and Latex styles are supported.
Haskell interfaces to C code used by hsc2hs pre-processor.
Haskell source with CPP pragmas used with cpphs pre-processor.
Haskell FFI bindings to C libraries used with c2hs pre-processor.
Haskell Mode offers many productivity tools described in following chapters in this manual.
There are a few functions for managing imports.
To jump to your import list, run
It’s nicer to have a keybinding to do this, for example:
(define-key haskell-mode-map (kbd "<f8>") 'haskell-navigate-imports)
You can hit it repeatedly to jump between groups of imports. It will cycle.
To generally format (sort, align) your imports, you can run
Or C-c C-,.
To just sort imports, jump to an import section and run
To just align imports, jump to an import section and run
As an alternative to the elisp functions described above, haskell-mode
can use the program
stylish-haskell to format imports. You can set this behavior by
haskell-stylish-on-save. You can install
stylish-haskell by running
stylish-haskell, or if you have not installed
cabal install stylish-haskell.
haskell-mode can generate tags when saving source files. To
haskell-mode uses external program —
(wiki-article). To turn on tags
generatation customize or set to
variable. Also, you may find useful to revert tags tables
automatically, this can be done by customizing
tags-revert-without-query variable (either globally or for
Haskell buffers only).
When profiling code with GHC, it is often useful to add
cost centres by hand. These allow finer-grained information about
haskell-mode provides the function
haskell-mode-toggle-scc-at-point to make this more convenient.
It will remove an SCC annotation at point if one is present, or add
one if point is over whitespace. By default it is bound to C-c C-s.