10.1145/1411204.1411257acmconferencesArticle/Chapter ViewAbstractPublication PagesicfpConference Proceedingsconference-collections
research-article

Quotient lenses

Published:20 September 2008Publication History

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

Video

References

  1. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  2. 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 ScholarGoogle Scholar
  3. François Bancilhon and Nicolas Spyratos. Update semantics of relational views. ACM Transactions on Database Systems, 6(4):557--575, December 1981. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. Nick Benton. Embedded interpreters. Journal of Functional Programming, 15(4):503--542, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Meera Blattner. Single-valued a-transducers. Journal of Computer and System Sciences, 15(3):310--327, 1977.Google ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  9. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  10. A. Cunha, J. N. Oliveira, and J. Visser. Type-safe two-level data transformation. European Symposium on Formal Methods, 4085:284--299. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. Umeshwar Dayal and Philip A. Bernstein. On the correct translation of update operations on relational views. TODS, 7(3):381--416, September 1982. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. David T. Eger. Bit level types, 2005. Manuscript. Available from http://www.yak.net/random/blt/blt-drafts/03/blt.pdf.Google ScholarGoogle Scholar
  13. 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 ScholarGoogle Scholar
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. Michael Greenberg and Shriram Krishnamurthi. Declarative Composable Views, 2007. Undergraduate Honors Thesis. Department of Computer Science, Brown University.Google ScholarGoogle Scholar
  19. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  22. Andrew J. Kennedy. Functional pearl: Pickler combinators. Journal of Functional Programming, 14(6):727--739, 2004. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  24. David Lutterkort. Augeas: A Linux configuration API, February 2007. Available from http://augeas.net/.Google ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. Lambert Meertens. Designing constraint maintainers for user interaction, 1998. Manuscript.Google ScholarGoogle Scholar
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle ScholarCross RefCross Ref
  29. Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi. Bidirectionalizing tree transformation languages: A case study. JSSST Computer Software, 23(2): 129--141, 2006.Google ScholarGoogle Scholar
  30. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  32. 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 ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Quotient lenses

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader
    About Cookies On This Site

    We use cookies to ensure that we give you the best experience on our website.

    Learn more

    Got it!