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]  Nicolas Spyratos,et al.  Update semantics of relational views , 1981, TODS.

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

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

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

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

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

[7]  Lambert Meertens,et al.  Designing Constraint Maintainers for User Interaction , 1998 .

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

[9]  David T Eger Bit Level Types , 2005 .

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

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

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

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

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

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

[16]  Michael Greenberg Brown Declarative, composable views , 2008 .

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

[18]  Claus Brabrand,et al.  Dual syntax for XML languages , 2005, Inf. Syst..

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

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

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

[22]  Nate Foster,et al.  Combinators for bi-directional tree transformations: a linguistic approach to the view update problem , 2005, POPL '05.

[23]  J KennedyAndrew FUNCTIONAL PEARL Pickler combinators , 2004 .

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

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

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

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

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

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

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