Skip to content


Subversion checkout URL

You can clone with
Download ZIP
The Haskell Refactoring Tool
Haskell TeX HTML Bison Emacs Lisp Shell Other
#22 Compare This branch is 1147 commits ahead of RefactoringTools:master.
Failed to load latest commit information.
docker wip
docs Typo
elisp Change the refactored file name to still have the original extension,…
experiments Starting to integrate DualTree
hareview Capture latest hareview state, to clean up workspace
hcar Draft update for HCAR 2015-05
misc Merge branch 'hp2013-2'
old Getting rid of some old files no longer needed.
src lower bounds on parsec and haskell-token-utils, v0.7.2.8
test Fix tests for new showToken format
.ghci Reverting to ghc-mod 4.x, preparing release
.gitignore Working in new version of haskell-token-utils
.travis.yml Ignore GHC 7.8 build failure
ChangeLog lower bounds on parsec and haskell-token-utils, v0.7.2.8
GHC-NOTES Getting to grips with hsVisiblePNs. And GHC Renamer phase.
HaRe.cabal lower bounds on parsec and haskell-token-utils, v0.7.2.8
HaReLogo.svg Doc tweaks Setting lower bound on Diff dependency. Closes #7
LICENSE Update license
NOTES WIP. Making progress.
README.markdown Add HCAR entry
Setup.hs Adding files that are in the hackage HaRe- package, but not in…
Setup.lhs Added somewhat working cabal project file.
TODO Introduced MonadPlus for RefactGhc, and Strafunski StrategyLib WIP WIP. Does not want to load files properly if not in project directory Cleaning up Experimenting with docker


HaRe : The Haskell Refactorer

Available on Hackage License BSD3 Build Status

Note: The current version ( does not install with GHC 7.8.x


The token management utilities haskell-token-utils are too brittle, and will not be updated for GHC 7.8.x and beyond.

There are substantial changes coming in GHC 7.10, which will form the basis of the new token management, based on ghc-exactprint

For coming changes in GHC 7.10, see

Getting Started

cabal install HaRe

Check that it works from the command line

$ ghc-hare --version

Running the bare command lists available refactorings and their parameters

Emacs integration

Currently only emacs integration is offered. Add the following to your ~/.emacs using the load-path entry that matches the installation on your machine.

(add-to-list 'load-path
(add-to-list 'load-path
(require 'hare)
(autoload 'hare-init "hare" nil t)

Add an intializer hook to the ghc-mode command

(add-hook 'haskell-mode-hook (lambda () (ghc-init) (hare-init)))

Alternatively, if using haskell-mode, and initializing via a function

;; Haskell main editing mode key bindings.
(defun haskell-hook ()

  ;(lambda nil (ghc-init))

If this is done correctly, there should be an additional Refactorer menu entry when opening a haskell file. The refactorings can be initiated via the menu, or using the keyboard shortcuts displayed in the menu.

The installation can be fine-tuned using

M-x customize-variable



Each refactoring will first ask for any information it requires, e.g. a new name if renaming, and then attempt the refactoring. If any precondition is not met this will be reported and the refactoring will abort.

If it succeeds, you will be given the option to look at an ediff session to see what changes would be made, and each file can be individually accepted or declined.

If the refactoring is commited, the original file is renamed to have a suffix containing the current timestamp.

E.g., after renaming in Foo.hs, there will be two files


This allows a sequence of refactorings to be undone manually if required. In theory.

Development & Support

Join in at #haskell-refactorer on freenode.

Developing in sandbox with haskell-token-utils locally

cabal clean
cabal sandbox init
# Next line assumes haskell-token-utils checked out at same level
cabal sandbox add-source ../haskell-token-utils/
cabal install --dependencies-only

Running test suite

To run the test suite do:

cabal configure --enable-tests && cabal build && cabal test

See for details on hspec

see for continuous build results


Coding style

Contributors: please try to follow Note:A consistent coding layout style is more important than what specific on is used.


  • Simon Thompson
  • Christopher Brown
  • Huiqing Li
  • Alan Zimmerman

Please put a pull request for this list if you are missing.


The logo was designed by Christi du Toit,

Something went wrong with that request. Please try again.