ABSTRACT
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.
Supplemental Material
Available for Download
Supplemental material for: Quotient lenses
References
- Artem Alimarine, Sjaak Smetsers, Arjen van Weelden, Marko van Eekelen, and Rinus Plasmeijer. There and back again: Arrows for invertible programming. In ACM SIGPLAN Workshop on Haskell, pages 86--97, 2005. Google Scholar
Digital Library
- Amos Bairoch, Rolf Apweiler, Cathy H. Wu, Winona C. Barker, Brigitte Boeckmann, Serenella Ferro, Elisabeth Gasteiger, Hongzhan Huang, Rodrigo Lopez, Michele Magrane, Maria J. Martin, Darren A. Natale, Claire O'Donovan, Nicole Redaschi, and Lai. The Universal Protein Resource (UniProt). Nucleic Acids Research, 33 (Database issue):D154--9, January 2005.Google Scholar
- François Bancilhon and Nicolas Spyratos. Update semantics of relational views. ACM Transactions on Database Systems, 6(4):557--575, December 1981. Google Scholar
Digital Library
- Nick Benton. Embedded interpreters. Journal of Functional Programming, 15(4):503--542, 2005. Google Scholar
Digital Library
- Pablo Berdaguer, Alcino Cunha, Hugo Pacheco, and Joost Visser. Coupled schema transformation and data conversion for XML and SQL. In International Symposium on Practical Aspects of Declarative Languages (PADL), Nice France, volume 4354, pages 290--304, 2007. Google Scholar
Digital Library
- Meera Blattner. Single-valued a-transducers. Journal of Computer and System Sciences, 15(3):310--327, 1977.Google Scholar
Cross Ref
- Aaron Bohannon, Jeffrey A. Vaughan, and Benjamin C. Pierce. Relational lenses: A language for updateable views. In Principles of Database Systems (PODS), 2006. Extended version available as University of Pennsylvania technical report MS-CIS-05-27. Google Scholar
Digital Library
- Aaron Bohannon, J. Nathan Foster, Benjamin C. Pierce, Alexandre Pilkiewicz, and Alan Schmitt. Boomerang: Resourceful lenses for string data. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), San Francisco, California, January 2008. Google Scholar
Digital Library
- Claus Brabrand, Anders Møller, and Michael I. Schwartzbach. Dual syntax for XML languages. Information Systems, 2007. To appear. Extended abstract in Database Programming Languages (DBPL) 2005. Google Scholar
Digital Library
- A. Cunha, J. N. Oliveira, and J. Visser. Type-safe two-level data transformation. European Symposium on Formal Methods, 4085:284--299. Google Scholar
Digital Library
- Umeshwar Dayal and Philip A. Bernstein. On the correct translation of update operations on relational views. TODS, 7(3):381--416, September 1982. Google Scholar
Digital Library
- David T. Eger. Bit level types, 2005. Manuscript. Available from http://www.yak.net/random/blt/blt-drafts/03/blt.pdf.Google Scholar
- Sander Evers, Peter Achten, and Rinus Plasmeijer. Disjoint forms in graphical user interfaces. In Trends in Functional Programming, volume 5, pages 113--128. Intellect, 2006. ISBN 1-84150-144-1.Google Scholar
- Kathleen Fisher and Robert Gruber. PADS: a domain-specific language for processing ad hoc data. In ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI), Chicago, IL, pages 295--304, 2005. Google Scholar
Digital Library
- J. Nathan Foster, Michael B. Greenwald, Christian Kirkegaard, Benjamin C. Pierce, and Alan Schmitt. Exploiting schemas in data synchronization. Journal of Computer and System Sciences, 73(4):669--689, June 2007a. Extended abstract in Database Programming Languages (DBPL) 2005. Google Scholar
Digital Library
- J. Nathan Foster, Michael B. Greenwald, Jonathan T. Moore, Benjamin C. Pierce, and Alan Schmitt. Combinators for bi-directional tree transformations: A linguistic approach to the view update problem. ACM Transactions on Programming Languages and Systems, 29(3):17, May 2007b. Extended abstract in Principles of Programming Languages (POPL), 2005. Google Scholar
Digital Library
- J. Nathan Foster, Benjamin C. Pierce, and Alexandre Pilkiewicz. Quotient lenses. Technical Report MS-CIS-08-08, Dept. of CIS University of Pennsylvania, 2008.Google Scholar
Digital Library
- Michael Greenberg and Shriram Krishnamurthi. Declarative Composable Views, 2007. Undergraduate Honors Thesis. Department of Computer Science, Brown University.Google Scholar
- Stephen J. Hegner. Foundations of canonical update support for closed database views. In International Conference on Database Theory (ICDT), Paris, France, pages 422--436, New York, NY, USA, 1990. Springer-Verlag New York, Inc. ISBN 0-387-53507-1. URL http://www.cs.umu.se/hegner/Publications/PDF/icdt90.pdf. Google Scholar
Digital Library
- Zhenjiang Hu, Shin-Cheng Mu, and Masato Takeichi. A programmable editor for developing structured documents based on bi-directional transformations. In Partial Evaluation and Program Manipulation (PEPM), pages 178--189, 2004. Extended version to appear in Higher Order and Symbolic Computation, 2008. Google Scholar
Digital Library
- Shinya Kawanaka and Haruo Hosoya. bixid: a bidirectional transformation language for XML. In ACM SIGPLAN International Conference on Functional Programming (ICFP), Portland, Oregon, pages 201--214, 2006. Google Scholar
Digital Library
- Andrew J. Kennedy. Functional pearl: Pickler combinators. Journal of Functional Programming, 14(6):727--739, 2004. Google Scholar
Digital Library
- Dongxi Liu, Zhenjiang Hu, and Masato Takeichi. Bidirectional interpretation of xquery. In ACM SIGPLAN Symposium on Partial Evaluation and Semantics-based Program Manipulation (PEPM), Nice, France, pages 21--30, New York, NY, USA, 2007. Google Scholar
Digital Library
- David Lutterkort. Augeas: A Linux configuration API, February 2007. Available from http://augeas.net/.Google Scholar
- K. Matsuda, Z. Hu, K. Nakano, M. Hamana, and M. Takeichi. Bidirectionalization transformation based on automatic derivation of view complement functions. In ACM SIGPLAN International Conference on Functional Programming (ICFP), volume 42, pages 47--58. ACM Press New York, NY, USA, 2007. Google Scholar
Digital Library
- Lambert Meertens. Designing constraint maintainers for user interaction, 1998. Manuscript.Google Scholar
- Renée J. Miller, Mauricio, A. Hernandez, Laura M. Haas, Lingling Yan, C. T. Howard Ho, Ronald Fagin, and Lucian Popa. The clio project: Managing heterogeneity. 30(1):78--83, March 2001. URL citeseer.nj.nec.com/miller01clio.html. Google Scholar
Digital Library
- Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi. An algebraic approach to bi-directional updating. In ASIAN Symposium on Programming Languages and Systems (APLAS), pages 2--20, November 2004.Google Scholar
Cross Ref
- Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi. Bidirectionalizing tree transformation languages: A case study. JSSST Computer Software, 23(2): 129--141, 2006.Google Scholar
- Norman Ramsey. Embedding an interpreted language using higher-order functions and types. In ACM SIGPLAN Workshop on Interpreters, Virtual Machines and Emulators (IVME), San Diego, CA, pages 6--14, 2003. Google Scholar
Digital Library
- Perdita Stevens. Bidirectional model transformations in QVT: Semantic issues and open questions. In International Conference on Model Driven Engineering Languages and Systems (MoDELS), Nashville, TN, volume 4735 of Lecture Notes in Computer Science, pages 1--15. Springer-Verlag, 2007. ISBN 978-3-540-75208-0. Google Scholar
Digital Library
- Yingfei Xiong, Dongxi Liu, Zhenjiang Hu, Haiyan Zhao, Masato Takeichi, and Hong Mei. Towards automatic model synchronization from model transformations. In IEEE/ACM International Conference on Automated Software Engineering (ASE), Atlanta, Georgia, pages 164--173, 2007. Google Scholar
Digital Library
Index Terms
Quotient lenses






Comments