Refactoring Functional Programs

http://www.cs.kent.ac.uk/projects/refactor-fp/


Refactoring is about `improving the design of existing code' and as such, it has been practised as long as programs have been written. The term refactoring specifically refers to a common activity in programming and software maintenance: changing the structure of a program without changing its semantics. Often, refactoring precedes a program modification or extension, bringing the program into a form better suited for the modification step. Sometimes, refactoring is of anticipatory nature -- bringing a program into a nice shape after making it work, in the hope to facilitate reuse and maintenance. There are obvious relations to the general issues of reengineering old systems for new purposes, but the key point is to separate changes to how the program is organised (refactoring) from changes to what the program does.

Refactoring was first identified as an activity in its own right within the object-oriented programming and software engineering communities, and it has become popular there in the form of catalogues documenting sequences of refactoring steps and tool support for carrying out refactorings (see www.refactoring.com). The aim of our research is bring the advantages of refactoring to functional programmers, with a specific focus on support for Haskell programmers. This focus serves to keep our work concrete and practical, not to exclude other functional languages.

We will be complementing our work with an EPSRC-supported project to investigate refactoring of Erlang programs, starting summer 2005. We are also very keen to recruit PhD students in refactoring and functional programming; a number of concrete project suggestions can be found here. Please get in touch with us if you would be interested to become part of our functional programming group


Final report: The final report explaining the work done on the project.

Software: HaRe, the Haskell Refactorer (work in progress; snapshots of our prototype have been available here since after the Haskell Workshop 2003).
You can also use darcs to get the latest development release -- darcs get http://www.cs.kent.ac.uk/projects/refactor-fp/release

Investigators: Simon Thompson and Claus Reinke

Research Assistant: Huiqing Li

PhD students: Huiqing Li and Chris Brown

Student interns (2004): Jonathan Cowie and Nguyen Viet Chau.

Related project : Refactoring Erlang programs.

Publications and Presentations:

Related work: [functional languages] [non-functional languages] [general (transformation, tool generators, ..)] Jose Proenca's thesis.

Acknowledgements: The project is partially funded by an EPSRC grant. Our Haskell Refactorer builds on Programatica's Haskell-in-Haskell frontend and on Strafunski's support for generic and strategic programming.


News

September 2006:

Huiqing gave a presentation on A Comparative Study of Refactoring Haskell and Erlang Programs at SCAM 2006.

June 2006:

Several new refactorings have been added to HaRe, these are part of the development version, which can be downloaded from darcs.

 

HaRe has been re-engineered to compile with ghc 6.5. Part of this decision was becuase several new refactorings have been added that require the use of the GHC type-checker. All the existing snapshot still compile fine with ghc 6.4.

 

Chris has produced a small paper on type based refactorings for the Computer Science Postgraduate Conference, here at the University of Kent. A copy of the paper is available to download.

 

Chris has produced a small proposal with what he intends to pursue on the remainder of his PhD. A copy is avaible to download.

March 2006:

Huiqing gave a presentation on Refactoring Haskell Programs vs Refactoring Erlang Programs here in the local FP-group meeting.

March 2006:

Huiqing gave a presentation on Refactoring Haskell Programs here in the local TCS group seminars.

February 2006:

ááááááááááá Chris produced a report for a refactoring to add a new constructor to a data type. The report can be downloaded here.

 

Darcs repository now available! Chris has set up a darcs repository for the latest development version of HaRe. To download, cd to the latest snapshot of HaRe and type darcs get http://www.cs.kent.ac.uk/projects/refactor-fp/release. You will need darcs available here .

January 2006:

ááááááááááá A new snapshot of HaRe 0.3, which is now compatible with the latest GHC and Programmatic, is available. A few new refactorings have also been added.

December 2005:

ááááááááááá Christoph Reichenbach from University of Colorado visited us, to talk about refactoring ML programs.

November 2005

ááááááááááá Our updated entry in the 9th edition of the Haskell Communities Report.

ááááááááááá Chris gave a talk at the fp group refactoring functional programs and program slicing .

ááááááááááá Chris set up a work related blog on his PhD work. The blog is public and can be accessed here. .

September 2005:

Huiqing gave a talk on the formalisation of Haskell refactorings at TFP'2005 in Tallinn, Estonia (slides).

August 2005:

Chris passsed his mini thesis on refactoring functional programs. The mini thesis can be downloaded here

April 2005:

Jose Proenca from the program transformation group in Braga is going to visit us, to learn about HaRe and its API.

April 2005:

Huiqing gave a tool demo on HaRe and its API at LDTA'2005 in Edinburgh (slides).

March 2005:

Martin Erwig visited us for a few days, to talk about monadification and adding it as a refactoring to HaRe. One of the outcomes was a survey on the Haskell mailing list, to find out which styles of monadification Haskellers actually use. So far, the feedback has been sparse, but varied and useful - please add your comments/preferences!-)

March 2005:

We visited the GHC team in Cambridge for a day, to talk about their work on a GHC API, and how we could make use of that for HaRe.

February 2005:

Chris Ryder joined our project for 3 months, to look into GHC API integration.

December 2004:

Nguyen Viet Chau has written a report on his summer internship project.

December 2004:

HaRe now has initial support for hierarchical modules.

November 2004:

Our updated entry in the 7th edition of the Haskell Communities Report

November 2004:

We announced the 19/11/2004 snapshot of HaRe as HaRe 0.3, adding some module- and data-oriented refactorings as well as a first version of the HaRe API.

October 2004:

Simon and Huiqing visited the PURe project (Program Understanding and Re-engineering) at Minho University in Portugal, presenting HaRe and its API.

September 2004:

Chris Brown joined our project as a new PhD student.

September 2004:

Simon presented our project during the ICFP 2004 poster session in Snowbird, Utah (poster).

August 2004:

There was a session on Refactoring Functional Programs at the 5th International Summer School on Advanced Functional Programming, Tartu, Estonia 14-21 August, 2004.

June 2004:

Tom Mens visited us. On 28 June 2004, he gave a TCS seminar "On the use of Graph Transformations for Software Refactoring".

June 2004:

Two summer interns, Jonathan Cowie and Nguyen Viet Chau, have joined the project to work on using our Haskell program transformation infra-structure for adding new transformations and discovery of opportunities for refactoring (such as code duplication). One of the outcomes we hope for is some documentation of how to extend HaRe, from someone who has to go through the process from scratch, and some suggestions on tailoring the existing APIs, all with the aim of enabling others to add their transformations to HaRe.

June 2004:

At the Workshop on Datatype-Generic Programming, Oxford 3rd and 4th June 2004, Huiqing gave a talk on HaRe as an application relying on generic programming techniques.

May 2004:

our updated entry in the sixth HC&AR

May 2004:

Simon gave a presentation at Kingston Business School.

March 2004:

Simon gave a presentation in Manchester.

February 2004:

Simon gave a presentation in Durham.

February 2004:

We held a one-day workshop here in Canterbury, on Monday, 09 February 2004. Slides or screenshots are now available for all presentations. It was a small workshop, by invitation only, and a very fruitful one - thanks to all participants!

January 2004:

We announced the 27/01/2004 snapshot of HaRe as HaRe 0.2.

December 2003:

We're working towards a new release of HaRe (making our refactorings module-aware) in January, and have started to provide snapshots again.

November 2003:

Huiqing gave a presentation on HaRe and its implementation here in the local TCS group seminars.

November 2003:

our updated entry in the fifth HC&AR

October 2003:

We've announced the October 01 snapshot of HaRe as HaRe 0.1.

September 2003:

We've started to provide snapshots of our HaRe prototype.

August 2003:

Claus gave a presentation about our project at the ACM Sigplan Haskell Workshop 2003 in Uppsala, Sweden, including a mini-demo of our Haskell Refactorer. The slides from the presentation (including a pseudo-demo) are available (also in PDF), the snapshot of the refactorer prototype used for the demo will be available here soon.

August 2003:

We've added an initial catalogue of refactorings to our webpages.

June 2003:

Our paper on 'Tool Support for Refactoring Functional Programs' has been accepted for the ACM Sigplan Haskell Workshop 2003, Uppsala, Sweden. It summarizes the current state of development (compressed Postscript; please note the ACM copyright).

May 2003:

Great relief: the Programatica team have decided to go for a BSD-style license for their Haskell-in-Haskell frontend, eliminating a big question mark over parts of the meta-programming infrastructure needed for our Haskell Refactorer.

May 2003:

Simon gave an invited talk on Refactoring Functional Programs at the 7th Brazilian Symposium on Programming Languages. An extended abstract focussing on 'A Case Study in Refactoring Functional Programs' accompanies the talk (this updates and replaces our earlier techreport). The slides from the presentation are also available.

May 2003:

Work on our Haskell Refactorer is progressing nicely, confirming the choices regarding tool infrastructure (the Programatica licensing question is still hanging in the air, though). A draft of our new paper on 'Tool Support for Refactoring Functional Programs' is available for comments (compressed Postscript). It summarizes the current state of development. [update: this has now been accepted for publication; see June for final version]

May 2003:

our updated entry in the fourth HC&AR

Older news:

Spring 2003:

We have started work on our Haskell Refactorer.

November 2002:

our first entry in the third HC&AR

Autumn 2002:

We have looked around for supporting infrastructure for our refactoring tools and, after a lot of prototyping to evaluate the few available alternatives, seem to have found suitable candidates in Programatica's Haskell-in-Haskell frontend and Strafunski's strategic programming library.

July 2002:

Haskell editing survey: In July, we invited Haskell programmers on the Haskell mailing list to let us know what editing tools they use when developing Haskell programs, so that we can get an idea of where our tools will have to fit in. You can see a (summary of survey results)

July 2002:

Huiqing Li joined us in early July as the research associate on our EPSRC project.

To fund further work we have applied for a grant: our case for support has led to EPSRC funding for the project and a new research associate.

Our work on refactoring is one of several projects in our very active local functional programming group.


Older Material, to be sorted away