Haskell mode for Emacs


Haskell-mode is a major Emacs mode for editing Haskell source code. It provides syntax highlighting and automatic indentation and comes with inf-haskell which allows interaction with an inferior Haskell interactive loop such as the one of Hugs or GHCi.

This release should work on any recent version of Emacs. If it doesn't, complain here, or discuss it on the mailing list. If it works on XEmacs, consider yourself lucky.


  1. Add these lines to your ~/.emacs init file:

    ; Haskell mode for Emacs
    (load "/util/haskell-mode/haskell-site-file")
    ;;  This only loads the bare-bones haskell-mode. To make it useful, you
    ;;  need additional modules; you can use the haskell customize-group
    ;;  to edit the Haskell mode hook or, if you prefer manual setup, try
    ;;  adding the following lines according to which modules you want to use:
    (add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
    (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
    ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-indent)
    ;;(add-hook 'haskell-mode-hook 'turn-on-haskell-simple-indent)
    ;;  Note that the three indentation modules are mutually exclusive - add at
    ;;  most one.  Note that the line of code for simple indentation is commented
    ;;  out (using a preceeding ;) in preference for the more advanced
    ;;  indentation module.  Installation is now complete!
    ;;The other modules are automatically loaded when needed in the following way:
    ;;- Font locking: just turn it on via `global-font-lock-mode' or do
    ;;  (add-hook 'haskell-mode-hook 'font-lock-mode)
    ;;- Declaration scanning: just use M-x imenu or bind `imenu' to a key.  E.g.
    ;;  (global-set-key [(control meta down-mouse-3)] 'imenu) or you can also add
    ;;  it to the menubar with (add-hook 'haskell-mode-hook 'imenu-add-menubar-index)
    ;;- Interaction with inferior Haskell interpreter: just hit C-c C-z  or  C-c C-l.

  2. Now use Emacs to open a .hs (haskell) file. Observe the color-contextual highlighting.

    % emacs echo.hs


  1. Stuart Shapiro, requestor.


  1. http://projects.haskell.org/haskellmode-emacs