[back to project home page]

HaRe -- The Haskell Refactorer

According to fable, a hare is a quick way to get from one tortoise to another, and back again -- but we probably got the moral wrong;-). If you think about big, lazy, 150 year-old Galapagos tortoises, you'll agree there's little similarity to your latest and greatest Haskell projects, and as for our HaRe, it doesn't race the full distance yet, and can't deal with all obstacles either. In Aesop's original version of the fable, there was only one tortoise (and instead of indistinguishable members of the tortoise family waiting at start and goal, the hare takes a nap during the race and is overtaken by the slow but steady tortoise), but then you could refactor a program to some normal form should you so choose; and just as the over-confident hare you'd be unlikely to win the race..

Sorry, where were we?-) Ah, yes: refactoring Haskell programs. Implementation of our HaRe prototype progresses nicely, and HaRe now supports about a dozen small refactorings such as renaming identifiers, moving/introducing/inlining definitions, and so on. Those refactorings are no longer limited to a single module, but are not yet supported by type analysis. HaRe can be accessed from either Vim or Emacs, on either Windows (win98/xp) or Unix/XWindows (Solaris). As planned, we made a first version available in the week after the Haskell workshop 2003, now followed by an updated version with multi-module support. You can also read about the current state of things in the paper we presented at that workshop: 'Tool Support for Refactoring Functional Programs' and in the slides of the presentation, which include a pseudo-demo (here are some screenshots from the example refactoring we used for the demo - sum to fold; using GVim). The refactorings supported so far are documented in an initial catalogue.

update 28/06/2010: An update of HaRe 0.6 (also known as HaRe 28/06/2010), which is compatible with GHC-6.12.1, is now available. Apart form a number of bug-fixes, a number of new refactorings have been added to HaRe. Some of these refactorings include: adding and removing fields and constructors to data-type definitions, folding and unfolding against as-patterns, merging and splitting function definitions, converting between let and where constructs, introduce pattern matching, gnerative folding, and a clone detection and elimination too. snapshot, README.

update 08/07/2009: An update of HaRe 0.5 which is compatible with GHC-6.8.2. A number of new refactorings have also been added. These include a number of structural and data-type based refactorings together with a duplicate code analysis and elimination tool.

HaRe 0.5 also releases a new version of the API, extended and maintained by the refactor-fp group.

HaRe 0.5 for ghc-6.8.2:

snapshot, README.

update 27/03/2008: An update of HaRe 0.4 which is now compatible with GHC-6.6.1 and GHC-6.8.2. A number of new refactorings have also been added. These include a suite of slicing utilities and some data-type and structural based refactorings.

Hare 0.4 also releases a new version of the API, extended and maintained by the refactor-fp group. The new API now includes type based anaylses and transformations for type-aware refactorings.

HaRe 0.4 for ghc-6.6.1:

snapshot, README.

HaRe 0.4 for ghc-6.8.2:

snapshot, README.

update 20/01/2006: An update of HaRe 0.3 which is now compatible with the latest GHC and Programmatica. A few new refactorings have also been added. snapshot, README.

update 15/04/2005: An update of HaRe 0.3 with a couple of bugs fixed.: snapshot, README.

update 11/03/2005: An update of HaRe 0.3 with a bug fixed.: snapshot, README.

update 03/12/2004: An update of HaRe 0.3 that includes the support for hierarchical modules and a bug fix. Adding refactoring command to the editor interface has been simplified. : snapshot, README.

19/11/2004: We announced a third release of HaRe, having added a number of module refactorings and data-oriented refactorings, and derived an API (documented using Haddock) for program analysis and transformation (also some bug fixes). THere is also an API available for the typed decorated AST. HaRe 0.3 is our 19/11/2004 snapshot, available here: snapshot, README. For those who would like to build their own refactorings or program transformations using HaRe as a framework, we have written and documented two sample refactorings: swapping the first two arguments of a function, and from if-then-else to case expression, you can also find the source code for these two refactorings from the refactorer directory in the release. The menus for these two sample refactorings are not in the Refactor menu in HaRe 0.3, however you can add them following the how to add a refactoring to the editor interface.

update 16/09/2004: An update of HaRe 0.2 that includes a couple bug fixes.: snapshot, README.

update 09/08/2004: An update of HaRe 0.2 that includes a new refactoring 'from concrete to abstract data type' and a couple of bug fixes.: snapshot, README.

update 26/04/2004: An update of HaRe 0.2 that includes a batch of new refactorings and another bug fix.: snapshot, README.

update 26/02/2004: An update of HaRe 0.2 that includes a workaround for ghc-6.2, an elisp interface that should work with both Emacs and XEmacs, and another batch of bug fixes; it also switches from replace-this occurrence to replace-all-occurrences in "Intro New Def": snapshot, README.

29/01/2004: We have announced a second release of HaRe, having made the refactorings module-aware (also initial support for literate Haskell, removal of some Emacs issues, and lots of bug fixes). HaRe 0.2 is our 27/01/2004 snapshot, available here: snapshot, README.

The snapshots include most generated sources and patched third-party code to minimize external and tool dependencies; seen to build and run on Windows ( 98 , XP ), Solaris , with gvim 6.2 , and with emacs 21.2.1 (we hope to have an xemacs version soon). Although we don't yet have confirmations for the current version, previous versions also worked on Linux (Redhat, Mandrake) , Mac OS X (10.2.6) (please let us know about other platforms). If you want to put HaRe's refactoring engine through its paces, there is also a test-suite (undocumented, needs HUnit; just unpack in the release directory, cd into testing, and run ./UTest.sh). Be warned that this is a snapshot of our current prototype - do not use this on your production code just yet!

The first release of HaRe (aka HaRe 0.1) was in October 2003, supporting only single-module refactorings.

Please send reports of problems, bugs, or successful installations on new platforms to refactor-fp (at kent.ac.uk).