Refactoring pattern matching
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 whi...
Main Authors: | , , , |
---|---|
Format: | Journal article |
Published: |
2013
|
_version_ | 1826264192510853120 |
---|---|
author | Wang, M Gibbons, J Matsuda, K Hu, Z |
author_facet | Wang, M Gibbons, J Matsuda, K Hu, Z |
author_sort | Wang, M |
collection | OXFORD |
description | 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 ensuremathrinv-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. © 2012 Elsevier B.V. All rights reserved. |
first_indexed | 2024-03-06T20:03:48Z |
format | Journal article |
id | oxford-uuid:283cc7ef-5595-49a7-baa0-cceeec28d9c0 |
institution | University of Oxford |
last_indexed | 2024-03-06T20:03:48Z |
publishDate | 2013 |
record_format | dspace |
spelling | oxford-uuid:283cc7ef-5595-49a7-baa0-cceeec28d9c02022-03-26T12:11:35ZRefactoring pattern matchingJournal articlehttp://purl.org/coar/resource_type/c_dcae04bcuuid:283cc7ef-5595-49a7-baa0-cceeec28d9c0Symplectic Elements at Oxford2013Wang, MGibbons, JMatsuda, KHu, ZDefining 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 ensuremathrinv-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. © 2012 Elsevier B.V. All rights reserved. |
spellingShingle | Wang, M Gibbons, J Matsuda, K Hu, Z Refactoring pattern matching |
title | Refactoring pattern matching |
title_full | Refactoring pattern matching |
title_fullStr | Refactoring pattern matching |
title_full_unstemmed | Refactoring pattern matching |
title_short | Refactoring pattern matching |
title_sort | refactoring pattern matching |
work_keys_str_mv | AT wangm refactoringpatternmatching AT gibbonsj refactoringpatternmatching AT matsudak refactoringpatternmatching AT huz refactoringpatternmatching |