Monadic combinators for "Putback" style bidirectional programming

Bidirectional transformations, in particular lenses, are programs with a forward get transformation and a backward putback transformation that keep source and view data types synchronized. Several bidirectional programming languages exist to aid programmers in writing a (sort of) forward transformation, and deriving a backward transformation for free. However, the maintainability offered by such languages comes at the cost of expressiveness and (more importantly) predictability because the ambiguity of synchronization "handled by the putback transformation" is solved by default strategies over which programmers have little control. In this paper, we argue that controlling such ambiguity is essential for bidirectional transformations and propose a novel language in which programmers write a (sort of) putback transformation, and get the unique get transformation for free. Like traditional bidirectional languages, our put-oriented language allows reasoning about the correctness of defined transformations from the properties of their building blocks. But it allows programmers to describe the behavior of a bidirectional transformation much more precisely, while retaining the maintainability of writing a single program. We demonstrate the practical power of the new approach through a series of examples, ranging from simple ones that illustrate traditional lenses to complex ones for which our putback-based approach is central to specifying nontrivial update strategies.

[1]  Jim Davies,et al.  Science of Computer Programming , 2014 .

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

[3]  James A. Larson,et al.  Updating relational views using knowledge at view definition and view update time , 1991, Inf. Syst..

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

[5]  Alcino Cunha,et al.  Calculating with lenses: optimising bidirectional transformations , 2011, PEPM '11.

[6]  Richard S. Bird,et al.  Algebra of programming , 1997, Prentice Hall International series in computer science.

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

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

[9]  Ulf Norell,et al.  Dependently typed programming in Agda , 2009, TLDI '09.

[10]  José Nuno Oliveira,et al.  Composing Least-change Lenses , 2013, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[11]  Arthur M. Keller,et al.  Choosing a View Update Translator by Dialog at View Definition Time , 1986, VLDB.

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

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

[14]  Michael Hanus,et al.  Curry: an integrated functional logic language (version 0 , 2003 .

[15]  Zhenjiang Hu,et al.  Delta Lenses over Inductive Types , 2012, Electron. Commun. Eur. Assoc. Softw. Sci. Technol..

[16]  Masato Takeichi Configuring Bidirectional Programs with Functions , 2009 .

[17]  S-C. Mu,et al.  An algebraic approach to bidirectional updating , 2004 .

[18]  Alcino Cunha,et al.  Generic Point-free Lenses , 2010, MPC.

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

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

[21]  Simon Marlow,et al.  Haskell 2010 Language Report , 2010 .

[22]  Erik Poll,et al.  Algebra of Programming by Richard Bird and Oege de Moor, Prentice Hall, 1996 (dated 1997). , 1999 .

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

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

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

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

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

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

[29]  Ralf Hinze,et al.  Just do it: simple monadic equational reasoning , 2011, ICFP.

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