Refactoring = Substitution + Rewriting: Towards Generic, Language-Independent Refactorings

Authors Simon Thompson , Dániel Horpácsi

Thumbnail PDF


  • Filesize: 0.54 MB
  • 9 pages

Document Identifiers

Author Details

Simon Thompson
  • School of Computing, University of Kent, Canterbury, UK
  • Faculty of Informatics, Eötvös Loránd University, Budapest, Hungary
Dániel Horpácsi
  • Faculty of Informatics, Eötvös Loránd University, Budapest, Hungary

Cite AsGet BibTex

Simon Thompson and Dániel Horpácsi. Refactoring = Substitution + Rewriting: Towards Generic, Language-Independent Refactorings. In Eelco Visser Commemorative Symposium (EVCS 2023). Open Access Series in Informatics (OASIcs), Volume 109, pp. 26:1-26:9, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2023)


Eelco Visser’s work has always encouraged stepping back from the particular to look at the underlying, conceptual problems. In that spirit we present an approach to describing refactorings that abstracts away from particular refactorings to classes of similar transformations, and presents an implementation of these that works by substitution and subsequent rewriting. Substitution is language-independent under this approach, while the rewrites embody language-specific aspects. Intriguingly, it also goes back to work on API migration by Huiqing Li and the first author, and sets refactoring in that general context.

Subject Classification

ACM Subject Classification
  • Software and its engineering → Software evolution
  • refactoring
  • generic
  • language independent
  • rewriting
  • substitution
  • API upgrade


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Thiago Tonelli Bartolomei, Krzysztof Czarnecki, and Ralf Lämmel. Swing to SWT and back: Patterns for API migration by wrapping. In Radu Marinescu, Michele Lanza, and Andrian Marcus, editors, 26th IEEE International Conference on Software Maintenance (ICSM 2010), September 12-18, 2010, Timisoara, Romania, pages 1-10. IEEE Computer Society, 2010. URL:
  2. Thiago Tonelli Bartolomei, Krzysztof Czarnecki, Ralf Lämmel, and Tijs Van Der Storm. Study of an API migration for two XML APIs. In International Conference on Software Language Engineering, pages 42-61. Springer, 2010. Google Scholar
  3. Péter Bereczky, Dániel Horpácsi, and Simon Thompson. A Proof Assistant Based Formalisation of a Subset of Sequential Core Erlang. In Aleksander Byrski and John Hughes, editors, Trends in Functional Programming, pages 139-158, Cham, 2020. Springer International Publishing. Google Scholar
  4. Martin Bravenboer, Karl Trygve Kalleberg, Rob Vermaas, and Eelco Visser. Stratego/XT 0.17. A language and toolset for program transformation. Sci. Comput. Program., 72, 2008. Google Scholar
  5. Dániel Drienyovszky, Dániel Horpácsi, and Simon Thompson. QuickChecking Refactoring Tools. In Scott Lystig Fritchie and Konstantinos Sagonas, editors, Erlang'10: Proceedings of the 2010 ACM SIGPLAN Erlang Workshop, pages 75-80. ACM SIGPLAN, 2010. Google Scholar
  6. Joseph Harrison, Simon Thompson, Steven Varoumas, and Reuben Rowe. API migration: compare transformed. In OCaml Workshop 2020, 2020. Google Scholar
  7. Dániel Horpácsi, Judit Kőszegi, and Zoltán Horváth. Trustworthy Refactoring via Decomposition and Schemes: A Complex Case Study. Electronic Proceedings in Theoretical Computer Science, 253:92-108, August 2017. URL:
  8. Marie-Christine Jakobs. PEQCHECK: Localized and Context-aware Checking of Functional Equivalence. In 2021 IEEE/ACM 9th International Conference on Formal Methods in Software Engineering (FormaliSE), pages 130-140, 2021. URL:
  9. Marie-Christine Jakobs and Maik Wiesner. PEQtest: Testing Functional Equivalence. In Einar Broch Johnsen and Manuel Wimmer, editors, Fundamental Approaches to Software Engineering, pages 184-204, Cham, 2022. Springer International Publishing. Google Scholar
  10. Günter Kniesel and Helge Koch. Static composition of refactorings. Science of Computer Programming, 52(1):9-51, 2004. Special Issue on Program Transformation. URL:
  11. Ralf Lämmel. Towards Generic Refactoring. In Proceedings of the 2002 ACM SIGPLAN Workshop on Rule-Based Programming, RULE '02, pages 15-28, New York, NY, USA, 2002. Association for Computing Machinery. URL:
  12. Huiqing Li and Simon Thompson. A Comparative Study of Refactoring Haskell and Erlang Programs. In M. Di Penta and L. Moonen, editors, Source Code Analysis and Manipulation, SCAM'06, 2006. Google Scholar
  13. Huiqing Li and Simon Thompson. Automated API Migration in a User-Extensible Refactoring Tool for Erlang Programs. In Tim Menzies and Motoshi Saeki, editors, Automated Software Engineering, ASE'12. IEEE Computer Society, 2012. Google Scholar
  14. Huiqing Li, Simon Thompson, György Orosz, and Melinda Töth. Refactoring with Wrangler, updated. In ACM SIGPLAN Erlang Workshop 2008, Victoria, British Columbia, Canada, 2008. Google Scholar
  15. Ralf Lämmel and Joost Visser. A Strafunski Application Letter. Information and Computation/information and Control - IANDC, pages 357-375, January 2003. URL:
  16. Jeff H. Perkins. Automatically Generating Refactorings to Support API Evolution. SIGSOFT Softw. Eng. Notes, 31(1):111-114, September 2005. URL:
  17. Retrie, a powerful, easy-to-use codemodding tool for Haskell., 2020. URL:
  18. Reuben Rowe, Hugo Férée, Simon Thompson, and Scott Owens. Characterising renaming within Ocaml’s module system: theory and implementation. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation, pages 950-965, 2019. Google Scholar
  19. Reuben Rowe, Hugo Férée, Simon Thompson, and Scott Owens. ROTOR: A Tool for Renaming Values in OCaml’s Module System. In 2019 IEEE/ACM 3rd International Workshop on Refactoring (IWoR), pages 27-30, 2019. URL:
  20. Max Schaefer and Oege de Moor. Specifying and Implementing Refactorings. SIGPLAN Not., 45(10):286-301, October 2010. URL:
  21. Hagen Schink, Martin Kuhlemann, Gunter Saake, and Ralf Lämmel. Hurdles in Multi-language Refactoring of Hibernate Applications. In ICSOFT 2011 - Proceedings of the 6th International Conference on Software and Database Technologies, volume 2, pages 129-134, January 2011. Google Scholar
  22. Friedrich Steimann. Constraint-Based Refactoring. ACM Trans. Program. Lang. Syst., 40(1), January 2018. URL:
  23. Nik Sultana and Simon Thompson. Mechanical Verification of Refactorings. In Workshop on Partial Evaluation and Program Manipulation. ACM SIGPLAN, 2008. Google Scholar
  24. Frank Tip, Robert M. Fuhrer, Adam Kieżun, Michael D. Ernst, Ittai Balaban, and Bjorn De Sutter. Refactoring Using Type Constraints. ACM Trans. Program. Lang. Syst., 33(3), May 2011. URL:
  25. Eelco Visser. Language Independent Traversals for Program Transformation. In J. Jeuring, editor, Proceedings of the Workshop on Generic Programming (WGP2000), Ponte de Lima, Portugal, July 2000. Technical Report, Department of Information and Computing Sciences, Universiteit Utrecht. Google Scholar
Questions / Remarks / Feedback

Feedback for Dagstuhl Publishing

Thanks for your feedback!

Feedback submitted

Could not send message

Please try again later or send an E-mail