School of Computing

A case study in refactoring functional programs

Simon Thompson and Claus Reinke

In Roberto Ierusalimschy, Lucilia Figueiredo, and Marcio Tulio Valente, editors, VII Brazilian Symposium on Programming Languages, pages 182-196. Sociedade Brasileira de Computacao, May 2003.


Refactoring is the process of redesigning existing code without changing its functionality. Refactoring has recently come to prominence in the OO community. In this paper we explore the prospects for refactoring functional programs.

Our paper centres on the case study of refactoring a 400 line Haskell program written by one of our students. The case study illustrates the type and variety of program manipulations involved in refactoring. Similarly to other program transformations, refactorings are based on program equivalences, and thus ultimately on language semantics. In the context of functional languages, refactorings can be based on existing theory and program analyses. However, the use of program transformations for program restructuring emphasises a different kind of transformation from the more traditional derivation or optimisation: characteristically, they often require wholesale changes to a collection of modules, and although they are best controlled by programmers, their application may require nontrivial semantic analyses.

The paper also explores the background to refactoring, provides a taxonomy for describing refactorings and draws some conclusions about refactoring for functional programs.

Download publication 93 kbytes (PDF)

Bibtex Record

author = {Simon Thompson and Claus Reinke},
title = {A Case Study in Refactoring Functional Programs},
month = {May},
year = {2003},
pages = {182-196},
keywords = {determinacy analysis, Craig interpolants},
note = {},
doi = {},
url = {},
    publication_type = {inproceedings},
    submission_id = {23192_1060160368},
    ISBN = {85-88442-45-0},
    booktitle = {VII Brazilian Symposium on Programming Languages},
    editor = {Roberto Ierusalimschy and Lucilia Figueiredo and Marcio Tulio Valente},
    organization = {Sociedade Brasileira de Computacao},
    refereed = {Invited talk},

School of Computing, University of Kent, Canterbury, Kent, CT2 7NF

Enquiries: +44 (0)1227 824180 or contact us.

Last Updated: 21/03/2014