Generic Recursive Lens Combinators and Their Calculation Laws
Ruifeng Xie,Zhenjiang Hu
DOI: https://doi.org/10.1016/j.tcs.2022.02.019
IF: 1.002
2022-01-01
Theoretical Computer Science
Abstract:Bidirectional transformation is a generic method for synchronizing two related data structures, with applications in databases, software model transformation, graph transformation, etc. Since the data to synchronize often have complicated and disparate structures, bidirectional transformations are hard to develop, correctly comprehend, reason about, or maintain. Programming language researchers have invested much efforts to invent new frameworks and paradigms, to aid the development of complex bidirectional transformations. However, these frameworks are not always applicable due to certain subtleties in the problem specification; some bidirectional programs become too complicated and unstructured to verify their correctness, not to mention their poor efficiency. In this paper, we propose a collection of generic recursion patterns for bidirectional transformations, and develop corresponding calculation laws. With these generic recursion patterns, we can develop structured bidirectional transformations, which are easy to understand and maintain. With these calculation laws, we can effectively optimize bidirectional programs, while preserving its very semantics. We demonstrate, through calculation of bidirectional transformations on trees, the expressiveness of the combinators and the effectiveness of the calculation laws. (c) 2022 Elsevier B.V. All rights reserved.