Refactoring Pattern Matching
Journal article, 2013

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.

functional programming

refactoring

abstract datatypes

fusion

invertible programming

pattern matching

Author

Meng Wang

Chalmers, Computer Science and Engineering (Chalmers), Software Engineering (Chalmers)

Jeremy Gibbons

University of Oxford

Kazutaka Matsuda

Tohoku University

Zhenjiang Hu

Research Organization of Information and Systems National Institute of Informatics

Science of Computer Programming

0167-6423 (ISSN)

Vol. 78 11 2216-2242

Areas of Advance

Information and Communication Technology

Subject Categories

Software Engineering

Computer Science

DOI

10.1016/j.scico.2012.07.014

More information

Latest update

9/21/2023