A Haskell 2010 refactoring tool. HaRe supports the full Haskell 2010 standard, through making use of the GHC API.

Version supports up to GHC 7.6.3.

There is no support for GHC 7.8.x. There will never be support for GHC 7.8.x

From version, GHC 7.10.2 is supported.

From version, GHC 8.0.1 is supported.

From version, GHC 8.0.2 is supported.

It is tested against GHC 7.10.3, GHC 8.0.1 and GHC 8.0.2 (via travis-ci.org)

It currently only has emacs integration built in, community input welcome for others.

HaRe attempts to operate in a safe way, by first writing new files with proposed changes, and only swapping these with the originals when the change is accepted. In the process the original file is renamed to have the current date/time as a suffix. Thus it should be possible to (manually) undo changes.

Even so, it is strongly advised to back up any source files before refactoring, as we can make no promises as to the reliability of this tool. Use at your own risk.

At the moment parsing of any file with FFI exports will fail.

See Language.Haskell.Refact.HaRe for the current list of refactorings supported


2017-02-11 v0.8.4.0
* Update for GHC 8.0.2
* Use ghc-mod version to 5.7
* Add deleteDef refactoring to generalise a monadic function
to use applicative (@SAdams601)
* Add genapplicative refactoring to generalise a monadic function
to use applicative (@SAdams601)
2016-08-03 v0.8.3.0
* Update for GHC 8.0.1
* Use ghc-mod version to 5.6 now it is released
2016-01-20 v0.8.2.3
* Use ghc-mod version to 5.5 now it is released
* Expose commands working in RefactGhc, so the ghc-mod session can
be shared in haskell-ide-engine. By @cocreature
* Internal only, heavily clean up the ...Refactoring.Rename
module. By @glittershark
2016-01-07 v0.8.2.2
* Lock ghc-mod version to 0.5.4 to prevent issues when 0.5.5 comes out
* Set minimum bound on ghc-exactprint, the behaviour of layout has
changed for ifToCase. This will be re-done once ghc-exactprint is
updated for GHC 8.0.1
* The constructors for ghc-mod `Options` are now re-exported too
for convenience.
2015-11-08 v0.8.2.1
* Set GHC-Opts to -O0 for sane compile times
* Make the ghc-hare depend on the library, rather than rebuilding
* elisp no longer prompts to save modified dired buffers
all of it.
2015-10-07 v0.8.2.0
* Work around a bug in GHC 7.10.2 that will not process pragmas
after a comment at the top of a file, when comments are returned
for ghc-exactprint processing.
* Add parameters to all use sites in the original location when
lifting a declaration.
2015-10-05 v0.8.1.1
* Move to new/old home at https://github.com/RefactoringTools/HaRe
2015-10-05 v0.8.1.0
* Reinstate processing of CPP directives as comments #36
* Fix problem in renaming in a client module when the old name is
not in scope in the client module. #35
* No longer mark a client module as refactored if no renaming
takes place in it.
2015-10-04 v0.8.0.0
* Major rework, replacing haskell-token-utils with ghc-exactprint
* Now supports GHC 7.10.2 and up. ONLY.
* Functionally equivalent to v0.7.2.8
2014-10-13 v0.7.2.8
lower bounds on parsec and haskell-token-utils
2014-08-20 v0.7.2.7
Upper bound on ghc-mod until 5.0 is released and stabilises
2014-07-20 v0.7.2.6
tokenise / basicTokenise moved to haskell-token-utils
2014-07-16 v0.7.2.5
Fix incompatibility with haskell-token-utils, closing
issue #14
2014-07-03 v0.7.2.4
Re-architect to split out haskell-token-utils as a separate
package, usable with haskell-src-exts too
2014-05-02 v0.7.2.3
* Update for ghc-mod 4.1.0
2014-04-03 v0.7.2.2
* Fix renaming so that it also renames types in the export list of
a module
* revert to ghc-mod >= 4.0, with note that FFI exports can't
currently be processed
2014-04-01 v0.7.2.1
* limit ghc-mod to <= 3.1.7, new version 4.0 does not deal with
FFI exports. This does not stop ghc-mod >= 4.0 being used in the
editor, it is just the library linked into ghc-hare
* Added disclaimer that API is subject to change without notice
* liftToTopLevel now brings along an updated type signature,
provided there are no constraints on any of the types
2014-03-23 v0.7.2.0
* Reorganised package structure to have
Language.Haskell.Refact.HaRe which provides all the functions
needed to call the refactorer from external code, and
Language.Haskell.Refact.API which provides the interfaces to write
new refactorings
* liftToMod of last local decl having preceding comment now removes 'where'
* Correctly determine the location for a demoted decl
2014-03-22 v0.7.1.7
* Correctly determine what parameters to add when lifting a decl
* Do not demote a decl if it is used in more than one match
2014-03-19 v0.7.1.6
* Do not treat single-line layout as a group, hence preserving
layout of adjacent let expressions when renaming.
* Process Template Haskell expressions instead of blowing up
2014-03-17 v0.7.1.5
* Adding parameters to lifted declarations now works as expected
2014-03-09 v0.7.1.4
* Load and process files using TH and/or QuasiQuotes
* Make loading of multiple targets from a cabal file more robust
2014-03-06 v0.7.1.3
* Various fixes for robustness based on real world trials
* Rework the free and declared variable calculation to be more accurate
* Extend the range of syntax elements that HaRe can handle when
reading a file. Most bar parallel extensions are in place.
* Make sure the refactored file retains its original extension, so
that syntax highlighting still works while the preview is being done.
2014-01-28 v0.7.1.2
* Ensure that the right target is activated for the primary file
when it belongs to a non-library target,not just for client
modules of it.
2014-01-27 v0.7.1.1
* The non-library targets were having the wrong path prepended
2014-01-26 v0.7.1.0
* Rework the module loading to load each target in turn, so that
all exe, test, benchmark etc will be refactored in one go
2013-12-18 v0.7.0.9
* Tweaks to output stage based on real world use. Renaming seems
stable, liftXXX, demote have issues
* Removed deprecated hspec-discover dependency
* added ghc-hare show command to the elisp as well to be able to
check that it is using the correct cabal file
2013-12-16 v0.7.0.8
* Major rewrite of the token output stage. It now makes use of a
dual-tree structure to manage the maintenance of required vertical
layout while refactoring.
2013-10-21 v0.7.0.7
* Bump the lower bound on Diff
2013-10-01 v0.7.0.6
* Sort out most of the do/in/let layout when renaming. Only nested
layout changes to be dealt with.
* Updated to use the latest ghc-mod, with cabal 1.18.x sandbox
* Updated to latest versions of Diff and hspec
* When refactoring a CPP pre-processed file, read the preprocessor
directives and non-compiled code as comments, so the source can be
round-tripped. This allows refactoring of simple #if/#else/#endif
code. NOTE: no refactoring is done on code that is not live after
the preprocessor.
2013-09-12 v0.7.0.5
* Now able to get tokens for a file pre-processed with CPP. But it
is the pre-processed output, so the CPP directives are stripped
out when writing out the refactored source.

2013-09-11 v0.7.0.4
* Correct Haddock compile error. Close #4
* hsWithBndrs only exists for GHC > 7.4.x
2013-09-10 v0.7.0.3

* Fix elisp, would not commit refactoring due to missing methods

2013-09-08 v0.7.0.2

* Fix issue #3: ifToCase formatting

2013-09-05 v0.7.0.1

* Fix issue #2: elisp

2013-09-04 v0.7.0.0

* Alpha release with new GHC API

comments powered byDisqus