An Expression Processor: A Case Study in Refactoring Haskell Programs

  • Christopher Brown
  • Huiqing Li
  • Simon Thompson
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 6546)


Refactoring is the process of changing the structure of a program while preserving its behaviour in order to increase code quality, programming productivity and code reuse. With the advent of refactoring tools, refactoring can be performed semi-automatically, allowing refactorings to be performed (and undone) easily.

In this paper, we briefly describe a number of new refactorings for Haskell 98 programs implemented in the Haskell Refactorer, HaRe. In particular, a number of new structural and data-type refactorings are presented. We also implement a simple expression processor, clearly demonstrating how the refactorings and the HaRe tool can aid programmers in developing Haskell software. We conclude the paper with a discussion of the benefits of refactoring Haskell programs, together with their implementation and design limitations.


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Brooks, F.P.: The Mythical Man-Month: After 20 Years. IEEE Software 12(5), 57–60 (1995)CrossRefGoogle Scholar
  2. 2.
    Opdyke, W.F.: Refactoring Object-Oriented Frameworks. PhD thesis, Department of Computer Science, University of Illinois at Urbana-Champaign, Champaign, IL, USA (1992)Google Scholar
  3. 3.
    Burstall, R.M., Darlington, J.: A Transformation System for Developing Recursive Programs. J. ACM 24(1), 44–67 (1977)MathSciNetCrossRefzbMATHGoogle Scholar
  4. 4.
    Li, H., Thompson, S., Reinke, C.: The Haskell Refactorer, HaRe, and its API. Electronic Notes in Theoretical Computer Science 141(4), 29–34 (2005); Proceedings of the Fifth Workshop on Language Descriptions, Tools, and Applications (LDTA 2005)CrossRefGoogle Scholar
  5. 5.
    Li, H., Reinke, C., Thompson, S.: Tool Support for Refactoring Functional Programs. In: ACM SIGPLAN 2003 Haskell Workshop, Association for Computing Machinery, pp. 27–38 (August 2003)Google Scholar
  6. 6.
    Peyton Jones, S., Hammond, K.: Haskell 98 Language and Libraries, the Revised Report. Cambridge University Press, Cambridge (2003)zbMATHGoogle Scholar
  7. 7.
    Refactor-fp Group, T.: The Haskell Editing Survey (2004),
  8. 8.
    Oualine, S.: Vim (Vi Improved). Sams (April 2001)Google Scholar
  9. 9.
    Cameron, D., Elliott, J., Loy, M.: Learning GNU Emacs. O’Reilly, Sebastopol (2004)Google Scholar
  10. 10.
    Hallgren, T.: Haskell Tools from the Programatica Project. In: Haskell 2003: Proceedings of the 2003 ACM SIGPLAN Workshop on Haskell, pp. 103–106. ACM Press, New York (2003)Google Scholar
  11. 11.
    Lämmel, R., Visser, J.: A Strafunski Application Letter. In: Dahl, V. (ed.) PADL 2003. LNCS, vol. 2562, pp. 357–375. Springer, Heidelberg (2002)CrossRefGoogle Scholar
  12. 12.
    Li, H.: Refactoring Haskell Programs. PhD thesis, School of Computing, University of Kent, Canterbury, Kent, UK (September 2006)Google Scholar
  13. 13.
    Brown, C.: Tool Support for Refactoring Haskell Programs. PhD thesis, School of Computing, University of Kent, Canterbury, Kent, UK (September 2008),
  14. 14.
    Brown, C., Thompson, S.: Clone Detection and Elimination for Haskell. In: Gallagher, J., Voigtlander, J. (eds.) PEPM 2010: Proceedings of the 2010 ACM SIGPLAN Workshop on Partial Evaluation and Program Manipulation, pp. 111–120. ACM Press, New York (2010)CrossRefGoogle Scholar
  15. 15.
    Refactor-fp Group, T.: Refactoring Functional Programs (2008),
  16. 16.
    Pettorossi, A.: A Powerful Strategy for Deriving Efficient Programs by Transformation. In: LFP 1984: Proceedings of the 1984 ACM Symposium on LISP and Functional Programming, pp. 273–281. ACM, New York (1984)CrossRefGoogle Scholar
  17. 17.
    Brown, C., Thompson, S.: Expression processor example code (2010),
  18. 18.
    Partsch, H., Steinbruggen, R.: Program Transformation Systems. ACM Comput. Surv. 15(3), 199–236 (1983)MathSciNetCrossRefGoogle Scholar
  19. 19.
    Hudak, P.: Conception, Evolution, and Application of Functional Programming Languages. ACM Computing Survey 21(3), 359–411 (1989)CrossRefGoogle Scholar
  20. 20.
    Mens, T., Tourwé, T.: A Survey of Software Refactoring. IEEE Trans. Softw. Eng. 30(2), 126–139 (2004)CrossRefGoogle Scholar
  21. 21.
    Kozsik, T., Csörnyei, Z., Horváth, Z., Király, R., Kitlei, R., Lövei, L., Nagy, T., Tóth, M., Víg, A.: Use cases for refactoring in erlang. In: Horváth, Z., Plasmeijer, R., Soós, A., Zsók, V. (eds.) Central European Functional Programming School. LNCS, vol. 5161, pp. 250–285. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  22. 22.
    Mattsson, H., Nilsson, H., Wikström, C., Ericsson Telecom Ab: Mnesia – A distributed robust DBMS for telecommunications applications. In: Gupta, G. (ed.) PADL 1999. LNCS, vol. 1551, pp. 152–163. Springer, Heidelberg (1999)CrossRefGoogle Scholar
  23. 23.
    Gill, A.: Introducing the Haskell Equational Reasoning Assistant. In: Proceedings of the 2006 ACM SIGPLAN Workshop on Haskell, pp. 108–109. ACM Press, New York (2006)CrossRefGoogle Scholar
  24. 24.
    Thompson, S.: Higher-order + Polymorphic = Reusable (May 1997)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2011

Authors and Affiliations

  • Christopher Brown
    • 1
  • Huiqing Li
    • 2
  • Simon Thompson
    • 2
  1. 1.School of Computer ScienceUniversity of St. AndrewsUK
  2. 2.School of ComputingUniversity of KentUK

Personalised recommendations