skip to main content
10.1145/2103656.2103715acmconferencesArticle/Chapter ViewAbstractPublication PagespoplConference Proceedingsconference-collections
research-article

Edit lenses

Published:25 January 2012Publication History

ABSTRACT

A lens is a bidirectional transformation between a pair of connected data structures, capable of translating an edit on one structure into an appropriate edit on the other. Many varieties of lenses have been studied, but none, to date, has offered a satisfactory treatment of how edits are represented. Many foundational accounts only consider edits of the form "overwrite the whole structure," leading to poor behavior in many situations by failing to track the associations between corresponding parts of the structures when elements are inserted and deleted in ordered lists, for example. Other theories of lenses do maintain these associations, either by annotating the structures themselves with change information or using auxiliary data structures, but every extant theory assumes that the entire original source structure is part of the information passed to the lens.

We offer a general theory of edit lenses, which work with descriptions of changes to structures, rather than with the structures themselves. We identify a simple notion of "editable structure"--a set of states plus a monoid of edits with a partial monoid action on the states--and construct a semantic space of lenses between such structures, with natural laws governing their behavior. We show how a range of constructions from earlier papers on "state-based" lenses can be carried out in this space, including composition, products, sums, list operations, etc. Further, we show how to construct edit lenses for arbitrary containers in the sense of Abbott, Altenkirch, and Ghani. Finally, we show that edit lenses refine a well-known formulation of state-based lenses, in the sense that every state-based lens gives rise to an edit lens over structures with a simple overwrite-only edit language, and conversely every edit lens on such structures gives rise to a state-based lens.

Skip Supplemental Material Section

Supplemental Material

popl_7b_3.mp4

mp4

138 MB

References

  1. 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
  2. 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
  3. 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
  4. Zinovy Diskin, Yingfei Xiong, Krzysztof Czarnecki, Hartmut Ehrig, Frank Hermann, and Fernando Orejas. From state- to delta-based bidirectional model transformations: The symmetric case. Technical Report GSDLAB-TR 2011-05-03, University of Waterloo, May 2011.Google ScholarGoogle ScholarCross RefCross Ref
  5. 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, 2007. ISSN 0164-0925. Extended abstract presented at Principles of Programming Languages (POPL), 2005. Google ScholarGoogle ScholarDigital LibraryDigital Library
  6. 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
  7. Martin Hofmann, Benjamin C. Pierce, and Daniel Wagner. Symmetric lenses. In ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL), Austin, Texas, January 2011. Google ScholarGoogle ScholarDigital LibraryDigital Library
  8. 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 in Higher Order and Symbolic Computation, Volume 21, Issue 1--2, June 2008. Google ScholarGoogle ScholarDigital LibraryDigital Library
  9. David Lutterkort. Augeas: A Linux configuration API, February 2007. Available from http://augeas.net/.Google ScholarGoogle Scholar
  10. Lambert Meertens. Designing constraint maintainers for user interaction, 1998. Manuscript.Google ScholarGoogle Scholar
  11. Shin-Cheng Mu, Zhenjiang Hu, and Masato Takeichi. An injective language for reversible computation. In Seventh International Conference on Mathematics of Program Construction (MPC), 2004.Google ScholarGoogle ScholarCross RefCross Ref
  12. 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
  13. 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
  14. 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
  15. 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. Edit 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
    • Published in

      cover image ACM Conferences
      POPL '12: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languages
      January 2012
      602 pages
      ISBN:9781450310833
      DOI:10.1145/2103656
      • cover image ACM SIGPLAN Notices
        ACM SIGPLAN Notices  Volume 47, Issue 1
        POPL '12
        January 2012
        569 pages
        ISSN:0362-1340
        EISSN:1558-1160
        DOI:10.1145/2103621
        Issue’s Table of Contents

      Copyright © 2012 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 25 January 2012

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • research-article

      Acceptance Rates

      Overall Acceptance Rate824of4,130submissions,20%

      Upcoming Conference

      POPL '25

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader