Symmetric Edit Lenses: A New Foundation for Bidirectional Languages

Lenses are bidirectional transformations between pairs of connected structures capable of translating an edit on one structure into an edit on the other. Most of the extensive existing work on lenses has focused on the special case of asymmetric lenses, where one structures is taken as primary and the other is thought of as a projection or view. Some symmetric variants exist, where each structure contains information not present in the other, but these all lack the basic operation of composition. Additionally, existing accounts do not represent edits carefully, making incremental operation difficult or producing unsatisfactory synchronization candidates. We present a new symmetric formulation which works with descriptions of changes to structures, rather than with the structures themselves. We construct a semantic space of edit lenses between “editable structures”—monoids of edits with a partial monoid action for applying edits—with natural laws governing their behavior. We present generalizations of a number of known constructions on asymmetric lenses and settle some longstanding questions about their properties—in particular, we prove the existence of (symmetric monoidal) tensor products and sums and the non-existence of full categorical products and sums in a category of lenses. Universal algebra shows how to build iterator lenses for structured data such as lists and trees, yielding lenses for operations like mapping, filtering, and concatenation from first principles. More generally, we provide mapping combinators based on the theory of containers. Finally, we present a prototype implementation of the core theory and take a first step in addressing the challenge of translating between user gestures and the internal representation of edits. Degree Type Dissertation Degree Name Doctor of Philosophy (PhD) Graduate Group Computer and Information Science First Advisor Benjamin C. Pierce

[1]  Brian Berliner,et al.  CVS II: Parallelizing Software Dev elopment , 1998 .

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

[3]  Maarten M. Fokkinga,et al.  Functional Programming with Bananas, Lenses, Envelopes and Barbed Wire , 1991, FPCA.

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

[5]  R Heckel Towards an Algebraic Theory of Bidirectional Transformations , 2015 .

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

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

[8]  Benjamin C. Pierce,et al.  Bidirectional programming languages , 2009 .

[9]  Varmo Vene,et al.  CATEGORICAL PROGRAMMING WITH INDUCTIVE AND COINDUCTIVE TYPES , 2000 .

[10]  Paul Mackerras,et al.  The rsync algorithm , 1996 .

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

[12]  Hartmut Ehrig,et al.  Correctness of model synchronization based on triple graph grammars , 2011, MODELS'11.

[13]  J. W. Hunt,et al.  An Algorithm for Differential File Comparison , 2008 .

[15]  Michael Johnson,et al.  Spans of lenses , 2014, EDBT/ICDT Workshops.

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

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

[18]  Shin-Cheng Mu,et al.  A programmable editor for developing structured documents based on bidirectional transformations , 2008, High. Order Symb. Comput..

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

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

[21]  Michael Johnson,et al.  View Updatability Based on the Models of a Formal Specification , 2001, FME.

[22]  R. A. G. Seely,et al.  Linear Logic, -Autonomous Categories and Cofree Coalgebras , 1989 .

[23]  Michael Johnson,et al.  Lenses, fibrations and universal translations† , 2011, Mathematical Structures in Computer Science.

[24]  Ryu Hasegawa,et al.  Two applications of analytic functors , 2002, Theor. Comput. Sci..

[25]  Thorsten Altenkirch,et al.  Foundations of Software Science and Computation Structures: 6th International Conference, FOSSACS 2003 Held as Part of the Joint European Conferences on Theory and Practice of Software, ETAPS 2003 Warsaw, Poland, April 7–11, 2003 Proceedings , 2003, Lecture Notes in Computer Science.

[26]  Benjamin C. Pierce,et al.  What's in Unison? A Formal Specification and Reference Implementation of a File Synchronizer , 2004 .

[27]  J. Robin B. Cockett,et al.  Shapely Types and Shape Polymorphism , 1994, ESOP.

[28]  Michael Johnson,et al.  Delta Lenses and Opfibrations , 2013, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[29]  P. Selinger A Survey of Graphical Languages for Monoidal Categories , 2009, 0908.3347.

[30]  Klaus Ostermann,et al.  Invertible syntax descriptions: unifying parsing and pretty printing , 2010 .

[31]  Michael Johnson,et al.  Lens put-put laws: monotonic and mixed , 2012, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[32]  Martin Hofmann,et al.  Symmetric lenses , 2011, POPL '11.

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

[34]  Samson Abramsky,et al.  Introduction to Categories and Categorical Logic , 2011, ArXiv.

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

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

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

[38]  A. Joyal Foncteurs analytiques et espèces de structures , 1986 .