Applicative bidirectional programming: Mixing lenses and semantic bidirectionalization

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. One way to reduce the development and maintenance effort of bidirectional transformations is to have specialized languages in which the resulting programs are bidirectional by construction—giving rise to the paradigm of bidirectional programming. In this paper, we develop a framework for applicative-style and higher-order bidirectional programming, in which we can write bidirectional transformations as unidirectional programs in standard functional languages, opening up access to the bundle of language features previously only available to conventional unidirectional languages. Our framework essentially bridges two very different approaches of bidirectional programming, namely the lens framework and Voigtlander's semantic bidirectionalization, creating a new programming style that is able to obtain benefits from both.

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

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

[3]  Philip Wadler,et al.  Idioms are Oblivious, Arrows are Meticulous, Monads are Promiscuous , 2011, Electron. Notes Theor. Comput. Sci..

[4]  Meng Wang,et al.  Enhancing semantic bidirectionalization via shape bidirectionalizer plug-ins , 2013, J. Funct. Program..

[5]  S. Lane Categories for the Working Mathematician , 1971 .

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

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

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

[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]  Zhenjiang Hu,et al.  BiGUL: a formally verified core language for putback-based bidirectional programming , 2016, PEPM.

[12]  Zhenjiang Hu,et al.  Monadic combinators for "Putback" style bidirectional programming , 2014, PEPM '14.

[13]  Ross Paterson,et al.  Constructing Applicative Functors , 2012, MPC.

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

[15]  Meng Wang,et al.  Refactoring pattern matching , 2013, Sci. Comput. Program..

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

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

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

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

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

[21]  Meng Wang,et al.  HOBiT: Programming Lenses Without Using Lens Combinators , 2018, ESOP.

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

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

[24]  Russell O'Connor,et al.  A representation theorem for second-order functionals , 2015, J. Funct. Program..

[25]  Gérard P. Huet,et al.  Proving and applying program transformations expressed with second-order patterns , 1978, Acta Informatica.

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

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

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

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

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

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

[32]  Frank Pfenning,et al.  Higher-order abstract syntax , 1988, PLDI '88.

[33]  Gopalan Nadathur,et al.  A Logic Programming Approach to Manipulating Formulas and Programs , 1987, SLP.

[34]  Meng Wang,et al.  Bidirectionalization for free with runtime recording: or, a light-weight approach to the view-update problem , 2013, PPDP.

[35]  Yijun Yu,et al.  Maintaining invariant traceability through bidirectional transformations , 2012, 2012 34th International Conference on Software Engineering (ICSE).

[36]  Alonzo Church,et al.  A formulation of the simple theory of types , 1940, Journal of Symbolic Logic.

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

[38]  Meng Wang,et al.  "Bidirectionalization for free" for monomorphic transformations , 2015, Sci. Comput. Program..

[39]  Meng Wang,et al.  Applicative bidirectional programming with lenses , 2015, ICFP.

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

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

[42]  Donald E. Knuth,et al.  A Web Service Architecture for Bidirectional XML Updating , 2006 .

[43]  Ross Paterson,et al.  A new notation for arrows , 2001, ICFP '01.

[44]  Russell O'Connor Functor is to Lens as Applicative is to Biplate: Introducing Multiplate , 2011, ArXiv.

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

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

[47]  Meng Wang,et al.  Semantic bidirectionalization revisited , 2014, PEPM '14.

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

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