skip to main content
research-article

Symmetric lenses

Authors Info & Claims
Published:26 January 2011Publication History
Skip Abstract Section

Abstract

Lenses--bidirectional transformations between pairs of connected structures--have been extensively studied and are beginning to find their way into industrial practice. However, some aspects of their foundations remain poorly understood. In particular, most previous work has focused on the special case of asymmetric lenses, where one of the structures is taken as primary and the other is thought of as a projection, or view. A few studies have considered symmetric variants, where each structure contains information not present in the other, but these all lack the basic operation of composition. Moreover, while many domain-specific languages based on lenses have been designed, lenses have not been thoroughly explored from an algebraic perspective.

We offer two contributions to the theory of lenses. First, we present a new symmetric formulation, based on complements, an old idea from the database literature. This formulation generalizes the familiar structure of asymmetric lenses, and it admits a good notion of composition. Second, we explore the algebraic structure of the space of symmetric lenses. We present generalizations of a number of known constructions on asymmetric lenses and settle some longstanding questions about their properties---in particular, we prove the existence of (symmetric monoidal) tensor products and sums and the non-existence of full categorical products or sums in the category of symmetric lenses. We then show how the methods of universal algebra can be applied to build iterator lenses for structured data such as lists and trees, yielding lenses for operations like mapping, filtering, and concatenation from first principles. Finally, we investigate an even more general technique for constructing mapping combinators, based on the theory of containers.

Skip Supplemental Material Section

Supplemental Material

34-mpeg-4.mp4

References

  1. M. Abbott, T. Altenkirch, and N. Ghani. Categories of containers. In Foundations of Software Science and Computation Structures, pages 23--38. Springer, 2003. Google ScholarGoogle ScholarDigital LibraryDigital Library
  2. Michael Abbott, Thorsten Altenkirch, and Neil Ghani. Containers: constructing strictly positive types. Theor. Comput. Sci., 342(1):3--27, 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. Samson Abramsky and Nikos Tzevelekos. Introduction to categories and categorical logic. In Bob Coecke, editor, New Structures for Physics. Springer, 2010.Google ScholarGoogle ScholarCross RefCross Ref
  4. 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
  5. Davi M. J. Barbosa, Julien Cretin, Nate Foster, Michael Greenberg, and Benjamin C. Pierce. Matching lenses: Alignment and view update. In ACM SIGPLAN International Conference on Functional Programming (ICFP), Baltimore, Maryland, September 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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
  7. 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
  8. Krzysztof Czarnecki, J. Nathan Foster, Zhenjiang Hu, Ralf Lämmel, Andy Schürr, and James F. Terwilliger. Bidirectional transformations: A cross-discipline perspective. In Richard F. Paige, editor, ICMT, volume 5563 of Lecture Notes in Computer Science, pages 260--283. Springer, 2009. ISBN 978-3--642-02407-8. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. Z. Diskin, K. Czarnecki, and M. Antkiewicz. Model-versioning-in the-large: algebraic foundations and the tile notation. In Proceedings of the 2009 ICSE Workshop on Comparison and Versioning of Software Models, pages 7--12. IEEE Computer Society, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  10. Zinovy Diskin. Algebraic models for bidirectional model synchronization. In Krzysztof Czarnecki, Ileana Ober, Jean-Michel Bruel, Axel Uhl, and Markus Völter, editors, MoDELS, volume 5301 of Lecture Notes in Computer Science, pages 21--36. Springer, 2008. ISBN 978-3--540-87874-2. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. 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 :17, May 2007. Extended abstract in Principles of Programming Languages (POPL), 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  12. J. Nathan Foster, Alexandre Pilkiewicz, and Benjamin C. Pierce. Quotient lenses. In ACM SIGPLAN International Conference on Functional Programming (ICFP), Victoria, Canada, September 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  13. John Nathan Foster. Bidirectional Programming Languages. PhD thesis, University of Pennsylvania, December 2009.Google ScholarGoogle ScholarDigital LibraryDigital Library
  14. R. Hasegawa. Two applications of analytic functors. Theoretical Computer Science, 272(1--2):113--175, 2002. Google ScholarGoogle ScholarDigital LibraryDigital Library
  15. S. Hidaka, Z. Hu, H. Kato, and K. Nakano. A compositional approach to bidirectional model transformation. In New Ideas and Emerging Results Track of 31st International Conference on Software Engineering (ICSE 2009, NIER Track), 2009.Google ScholarGoogle ScholarCross RefCross Ref
  16. S. Hidaka, Z. Hu, K. Inaba, H. Kato, K. Matsuda, and K. Nakano. Bidirectionalizing graph transformations. In ACM SIGPLAN International Conference on Functional Programming (ICFP), Baltimore, Maryland, September 2010. Google ScholarGoogle ScholarDigital LibraryDigital Library
  17. Zhenjiang Hu, Shin-Cheng Mu, and Masato Takeichi. A programmable editor for developing structured documents based on bidirectional 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
  18. C. Barry Jay and J. Robin B. Cockett. Shapely types and shape polymorphism. In Donald Sannella, editor, ESOP, volume 788 of Lecture Notes in Computer Science, pages 302--316. Springer, 1994. ISBN 3-540-57880-3. Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. A. Joyal. Foncteurs analytiques et especes de structures. Combinatoire énumérative, pages 126--159, 1986.Google ScholarGoogle Scholar
  20. 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
  21. David Lutterkort. Augeas: A Linux configuration API, February 2007. Available from http://augeas.net/.Google ScholarGoogle Scholar
  22. 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), pages 47--58. ACM Press New York, NY, USA, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library
  23. Lambert Meertens. Designing constraint maintainers for user interaction, 1998. Manuscript.Google ScholarGoogle Scholar
  24. E. Meijer, M. Fokkinga, and R. Paterson. Functional programming with bananas, lenses, envelopes and barbed wire. In Functional Programming Languages and Computer Architecture, pages 124--144. Springer, 1991. Google ScholarGoogle ScholarDigital LibraryDigital Library
  25. 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
  26. 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
  27. Perdita Stevens. A landscape of bidirectional model transformations. Postproceedings of GTTSE, 7, 2008.Google ScholarGoogle Scholar
  28. Perdita Stevens. Towards an algebraic theory of bidirectional transformations. In Graph Transformations: 4th International Conference, Icgt 2008, Leicester, United Kingdom, September 7-13, 2008, Proceedings, page 1. Springer, 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  29. Varmo Vene. Categorical Programming with Inductive and Coinductive Types. PhD thesis, Universitatis Tartuensis, 2000.Google ScholarGoogle Scholar
  30. Y. Xiong, H. Song, Z. Hu, and M. Takeichi. Supporting parallel updates with bidirectional model transformations. Theory and Practice of Model Transformations, pages 213--228, 2009. Google ScholarGoogle ScholarDigital LibraryDigital Library
  31. 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, GA, pages 164--173, 2007. Google ScholarGoogle ScholarDigital LibraryDigital Library

Index Terms

  1. Symmetric lenses

    Recommendations

    Comments

    Login options

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

    Sign in

    Full Access

    • Published in

      cover image ACM SIGPLAN Notices
      ACM SIGPLAN Notices  Volume 46, Issue 1
      POPL '11
      January 2011
      624 pages
      ISSN:0362-1340
      EISSN:1558-1160
      DOI:10.1145/1925844
      Issue’s Table of Contents
      • cover image ACM Conferences
        POPL '11: Proceedings of the 38th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
        January 2011
        652 pages
        ISBN:9781450304900
        DOI:10.1145/1926385

      Copyright © 2011 ACM

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 26 January 2011

      Check for updates

      Qualifiers

      • research-article

    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!