Refactoring pattern matching

Meng Wang, Jeremy Gibbons, Kazutaka Matsuda, Zhenjiang Hu

Research output: Contribution to journalArticlepeer-review

13 Citations (Scopus)


Defining functions by pattern matching over the arguments is advantageous for understanding and reasoning, but it tends to expose the implementation of a datatype. Significant effort has been invested in tackling this loss of modularity; however, decoupling patterns from concrete representations while maintaining soundness of reasoning has been a challenge. Inspired by the development of invertible programming, we propose an approach to program refactoring based on a right-invertible language rinv - every function has a right (or pre-) inverse. We show how this new design is able to permit a smooth incremental transition from programs with algebraic datatypes and pattern matching, to ones with proper encapsulation, while maintaining simple and sound reasoning.

Original languageEnglish
Pages (from-to)2216-2242
Number of pages27
JournalScience of Computer Programming
Issue number11
Publication statusPublished - 2013 Nov 1


  • Abstract datatypes
  • Functional programming
  • Fusion
  • Invertible programming
  • Pattern matching
  • Refactoring


Dive into the research topics of 'Refactoring pattern matching'. Together they form a unique fingerprint.

Cite this