Getting Started with Haskell

Table of Contents

1 The Haskell Platform

Install the platform for your respective operating system here.

2 Install haskell-mode

The haskell-mode package is a set of major modes for Emacs for writing Haskell code and working with Haskell projects. Features syntax highlighting, intelligent indentation, interaction with inferior Haskell interpreter, code browsing, and Cabal project integration. It support Hugs, GHCi, Cabal and hslint, hoogle, cabal-dev, and other utilities.

Find out more about it here http://www.haskell.org/haskellwiki/Haskell_mode_for_Emacs

2.1 Using the Emacs Package Manager

If you have Emacs 24, or have installed the Emacs package manager, you can simply use that to get haskell-mode. This is the best way to get haskell-mode, especially if you have semantic setup on your Emacs installation, as you will get Haskell library auto-completion too.

M-x package-install <RET> haskell-mode <RET>

2.2 Manually

If you don't have the package manager, you'll need to get haskell-mode yourself and tell Emacs about it manually.

Download haskell-mode from the github source and place it in your emacs configuration directory (default is ~/emacs.d/ but you can put it anywhere really). You will reference this below.

Then, add the following line to your emacs configuration file, the default is ~/.emacs, or ~/.emacs.d/init.el depending on your setup. Here, I've placed the package under ~/emacs/plugins/

(load "~/emacs/plugins/haskell-mode/haskell-site-file")

3 Configure Haskell-Mode

Like many major modes in Emacs, Haskell-mode is extremely configurable. Look at the details of what you can configure at the full how-to here.

The recommended configuration is to enable doc-mode and indentation. This will give you access to built-in documentation of Haskell library functions, as well as smart indentation of your Haskell code just as Emacs does with most languages.

To configure this, add the following lines to your emacs configuration file (~/.emacs or ~/.emacs.d/init.el):

(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)

And you're done!

4 Using haskell-mode

Haskell-mode's most useful features are all passively enabled, and you should feel at home programming in Haskell with just the TAB key.

4.1 The Haskell Interpreter C-c C-l

Launch a Haskell interpreter that loads the current file you are editing with the shortcut C-c C-l. This is very useful for dynamically interacting with your code within Emacs.

5 References

Author: Mishal Awadah

Date: 2012-11-14 17:49:49 EST

HTML generated by org-mode 7.3 in emacs 24