Quotient lenses

There are now a number of BIDIRECTIONAL PROGRAMMING LANGUAGES, where every program can be read both as a forward transformation mapping one data structure to another and as a reverse transformation mapping an edited output back to a correspondingly edited input. Besides parsimony - the two related transformations are described by just one expression - such languages are attractive because they promise strong behavioral laws about how the two transformations fit together - e.g., their composition is the identity function. It has repeatedly been observed, however, that such laws are actually a bit too strong: in practice, we do not want them "on the nose," but only up to some equivalence, allowing inessential details, such as whitespace, to be modified after a round trip. Some bidirectional languages loosen their laws in this way, but only for specific, baked-in equivalences. In this work, we propose a general theory of QUOTIENT LENSES - bidirectional transformations that are well behaved modulo equivalence relations controlled by the programmer. Semantically, quotient lenses are a natural refinement of LENSES, which we have studied in previous work. At the level of syntax, we present a rich set of constructs for programming with CANONIZERS and for quotienting lenses by canonizers. We track equivalences explicitly, with the type of every quotient lens specifying the equivalences it respects. We have implemented quotient lenses as a refinement of the bidirectional string processing language Boomerang. We present a number of useful primitive canonizers for strings, and give a simple extension of Boomerang's regular-expression-based type system to statically typecheck quotient lenses. The resulting language is an expressive tool for transforming real-world, ad-hoc data formats. We demonstrate the power of our notation by developing an extended example based on the UniProt genome database format and illustrate the generality of our approach by showing how uses of quotienting in other bidirectional languages can be translated into our notation.

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

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

[3]  José Nuno Oliveira,et al.  Type-Safe Two-Level Data Transformation , 2006, FM.

[4]  Shin-Cheng Mu,et al.  An Algebraic Approach to Bi-directional Updating , 2004, APLAS.

[5]  Perdita Stevens Bidirectional Model Transformations in QVT: Semantic Issues and Open Questions , 2007, MoDELS.

[6]  Marinus J. Plasmeijer,et al.  Disjoint forms in graphical user interfaces , 2004, Trends in Functional Programming.

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

[8]  Norman Ramsey,et al.  Embedding an interpreted language using higher-order functions and types , 2003, IVME '03.

[9]  Laura M. Haas,et al.  The Clio project: managing heterogeneity , 2001, SGMD.

[10]  Nick Benton,et al.  Under Consideration for Publication in J. Functional Programming Embedded Interpreters , 2022 .

[11]  Dongxi Liu,et al.  Towards automatic model synchronization from model transformations , 2007, ASE.

[12]  Robert Gruber,et al.  PADS: a domain-specific language for processing ad hoc data , 2005, PLDI '05.

[13]  Meera Blattner Single-Valued a-Transducers , 1977, J. Comput. Syst. Sci..

[14]  Shinya Kawanaka,et al.  biXid: a bidirectional transformation language for XML , 2006, ICFP '06.

[15]  Kazutaka Matsuda,et al.  Bidirectionalization transformation based on automatic derivation of view complement functions , 2007, ICFP '07.

[16]  Benjamin C. Pierce,et al.  Relational lenses: a language for updatable views , 2006, PODS '06.

[17]  Shin-Cheng Mu,et al.  A programmable editor for developing structured documents based on bidirectional transformations , 2004, PEPM '04.

[18]  Claus Brabrand,et al.  Dual Syntax for XML Languages , 2005, DBPL.

[19]  Shin-Cheng Mu,et al.  Bidirectionalizing Tree Transformation Languages: A Case Study , 2007 .

[20]  Andrew Kennedy,et al.  Pickler combinators , 2004, J. Funct. Program..

[21]  Umeshwar Dayal,et al.  On the correct translation of update operations on relational views , 1982, TODS.

[22]  Stephen J. Hegner,et al.  Foundations of Canonical Update Support for Closed Database Views , 1990, ICDT.

[23]  Dongxi Liu,et al.  Bidirectional interpretation of XQuery , 2007, PEPM '07.

[24]  Marko C. J. D. van Eekelen,et al.  There and back again: arrows for invertible programming , 2005, Haskell '05.

[25]  Joost Visser,et al.  Coupled schema transformation and data conversion for XML and SQL , 2007 .