Retentive Lenses

Based on Foster et al.'s lenses, various bidirectional programming languages and systems have been developed for helping the user to write correct data synchronisers. The two well-behavedness laws of lenses, namely Correctness and Hippocraticness, are usually adopted as the guarantee of these systems. While lenses are designed to retain information in the source when the view is modified, well-behavedness says very little about the retaining of information: Hippocraticness only requires that the source be unchanged if the view is not modified, and nothing about information retention is guaranteed when the view is changed. To address the problem, we propose an extension of the original lenses, called retentive lenses, which satisfy a new Retentiveness law guaranteeing that if parts of the view are unchanged, then the corresponding parts of the source are retained as well. As a concrete example of retentive lenses, we present a domain-specific language for writing tree transformations; we prove that the pair of get and put functions generated from a program in our DSL forms a retentive lens. We demonstrate the practical use of retentive lenses and the DSL by presenting case studies on code refactoring, Pombrio and Krishnamurthi's resugaring, and XML synchronisation.

[1]  Benjamin C. Pierce,et al.  Quotient lenses , 2008, ICFP 2008.

[2]  Martin Hofmann,et al.  Edit lenses , 2012, POPL '12.

[3]  Zhenjiang Hu,et al.  Delta Lenses over Inductive Types , 2012 .

[4]  James Cheney,et al.  Provenance in Databases: Why, How, and Where , 2009, Found. Trends Databases.

[5]  Hartmut Ehrig,et al.  From state- to delta-based bidirectional model transformations: the symmetric case , 2011, MODELS'11.

[6]  Eelco Visser,et al.  An Algorithm for Layout Preservation in Refactoring Transformations , 2011, SLE.

[7]  Thorsten Altenkirch,et al.  Containers: Constructing strictly positive types , 2005, Theor. Comput. Sci..

[8]  Nicolas Spyratos,et al.  Update semantics of relational views , 1981, TODS.

[9]  Perdita Stevens,et al.  Bidirectional model transformations in QVT: semantic issues and open questions , 2007, MODELS'07.

[10]  Shriram Krishnamurthi,et al.  Hygienic resugaring of compositional desugaring , 2015, ICFP.

[11]  Benjamin C. Pierce,et al.  Matching lenses: alignment and view update , 2010, ICFP '10.

[12]  Benjamin C. Pierce,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[13]  Guy L. Steele,et al.  The Java Language Specification, Java SE 8 Edition , 2013 .

[14]  Benjamin C. Pierce,et al.  Boomerang: resourceful lenses for string data , 2008, POPL '08.

[15]  Zhenjiang Hu,et al.  BiFluX: A Bidirectional Functional Update Language for XML , 2014, PPDP '14.

[16]  Arie van Deursen,et al.  Origin Tracking , 1993, J. Symb. Comput..

[17]  Klaus Ostermann,et al.  Invertible syntax descriptions: unifying parsing and pretty printing , 2010, Haskell '10.

[18]  Krzysztof Czarnecki,et al.  From State- to Delta-Based Bidirectional Model Transformations: the Asymmetric Case , 2011, J. Object Technol..

[19]  James Cheney,et al.  Provenance as dependency analysis† , 2007, Mathematical Structures in Computer Science.

[20]  Shriram Krishnamurthi,et al.  Resugaring: lifting evaluation sequences through syntactic sugar , 2014, PLDI.

[21]  Mauricio A. Saca Refactoring improving the design of existing code , 2017, 2017 IEEE 37th Central America and Panama Convention (CONCAPAN XXXVII).

[22]  Meng Wang,et al.  Incremental updates for efficient bidirectional transformations , 2011, ICFP '11.