Bidirectionalization for free with runtime recording: or, a light-weight approach to the view-update problem

A bidirectional transformation is a pair of mappings between source and view data objects, one in each direction. When the view is modified, the source is updated accordingly with respect to some laws. Over the years, a lot of effort has been made to offer better language support for programming such transformations. In particular, a technique known as bidirectionalization is able to analyze and transform unidirectional programs written in general purpose languages, and "bidirectionalize" them. Among others, a technique termed as semantic bidirectionalization proposed by Voigtländer stands out in term of user-friendliness. The unidirectional program can be written using arbitrary language constructs, as long as the function is polymorphic and the language constructs respect parametricity. The free theorems that follow from the polymorphic type of the program allow a kind of forensic examination of the transformation, determining its effect without examining its implementation. This is convenient, in the sense that the programmer is not restricted to using a particular syntax; but it does require the transformation to be polymorphic. In this paper, we lift this polymorphism requirement to improve the applicability of semantic bidirectionalization. Concretely, we provide a type class PackM γ α μ, which intuitively reads "a concrete datatype γ is abstracted to a type α, and the 'observations' made by a transformation on values of type γ are recorded by a monad μ". With PackM, we turn monomorphic transformations into polymorphic ones, that are ready to be bidirectionalized. We demonstrate our technique with a case study of standard XML queries, which were considered beyond semantic bidirectionalization because of their monomorphic nature.

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

[2]  James Cheney,et al.  Lenses for Web Data , 2013, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[3]  Leonidas Fegaras,et al.  Propagating updates through XML views using lineage tracing , 2010, 2010 IEEE 26th International Conference on Data Engineering (ICDE 2010).

[4]  Kazutaka Matsuda,et al.  Bidirectionalizing graph transformations , 2010, ICFP '10.

[5]  Conor McBride,et al.  Applicative programming with effects , 2008, J. Funct. Program..

[6]  Janis Voigtländer Bidirectionalization for free! (Pearl) , 2009, POPL '09.

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

[8]  Stephanie Weirich,et al.  Under Consideration for Publication in J. Functional Programming Parametricity, Type Equality and Higher-order Polymorphism , 2022 .

[9]  Meng Wang,et al.  Combining syntactic and semantic bidirectionalization , 2010, ICFP '10.

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

[11]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

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

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

[14]  Janis Voigtländer Free theorems involving type constructor classes: functional pearl , 2009, ICFP.

[15]  Colin Runciman,et al.  Haskell and XML: generic combinators or type-based translation? , 1999, ICFP '99.

[16]  Philip Wadler,et al.  Theorems for free! , 1989, FPCA.

[17]  Patrik Jansson,et al.  Proofs for free - Parametricity for dependent types , 2012, J. Funct. Program..

[18]  Ralf Lämmel,et al.  Bidirectional Transformations: A Cross-Discipline Perspective , 2009, ICMT@TOOLS.

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

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

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

[22]  Tom Schrijvers,et al.  Understanding idiomatic traversals backwards and forwards , 2013, Haskell '13.

[23]  Kazutaka Matsuda,et al.  Three Complementary Approaches to Bidirectional Programming , 2010, SSGIP.

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

[25]  Kazutaka Matsuda,et al.  Gradual Refinement , 2010, MPC.

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