TY - JOUR
T1 - Refactoring pattern matching
AU - Wang, Meng
AU - Gibbons, Jeremy
AU - Matsuda, Kazutaka
AU - Hu, Zhenjiang
N1 - Funding Information:
We are grateful to the anonymous reviewers of the earlier conference version of this paper [65] and of this revised and expanded version; we are especially grateful to Ralf Hinze for his valuable comments on an early draft of the paper—the binary number example is due to him. This work was supported by the UK Engineering and Physical Sciences Research Council through the Generic and Indexed Programming project (EP/E02128X) and a PhD Plus award on Bidirectional Programming via the Doctoral Training Grant (EP/P503876/1), and was partly conducted during Wang’s internship at National Institute of Informatics, Japan. Matsuda is supported by Grant-in-Aid for Start-up 22800003, and part of the work was done while he was at the University of Tokyo as JSPS Research Fellow supported by Grant-in-Aid for JSPS Fellows 20 · 9584.
PY - 2013/11/1
Y1 - 2013/11/1
N2 - 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.
AB - 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.
KW - Abstract datatypes
KW - Functional programming
KW - Fusion
KW - Invertible programming
KW - Pattern matching
KW - Refactoring
UR - http://www.scopus.com/inward/record.url?scp=84882449520&partnerID=8YFLogxK
UR - http://www.scopus.com/inward/citedby.url?scp=84882449520&partnerID=8YFLogxK
U2 - 10.1016/j.scico.2012.07.014
DO - 10.1016/j.scico.2012.07.014
M3 - Article
AN - SCOPUS:84882449520
SN - 0167-6423
VL - 78
SP - 2216
EP - 2242
JO - Science of Computer Programming
JF - Science of Computer Programming
IS - 11
ER -