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

Symmetric lenses

Published: 26 January 2011 Publication History

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.

Supplementary Material

MP4 File (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.
[2]
Michael Abbott, Thorsten Altenkirch, and Neil Ghani. Containers: constructing strictly positive types. Theor. Comput. Sci., 342(1):3--27, 2005.
[3]
Samson Abramsky and Nikos Tzevelekos. Introduction to categories and categorical logic. In Bob Coecke, editor, New Structures for Physics. Springer, 2010.
[4]
François Bancilhon and Nicolas Spyratos. Update semantics of relational views. ACM Transactions on Database Systems, 6(4):557--575, December 1981.
[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.
[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.
[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.
[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.
[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.
[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.
[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.
[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.
[13]
John Nathan Foster. Bidirectional Programming Languages. PhD thesis, University of Pennsylvania, December 2009.
[14]
R. Hasegawa. Two applications of analytic functors. Theoretical Computer Science, 272(1--2):113--175, 2002.
[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.
[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.
[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.
[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.
[19]
A. Joyal. Foncteurs analytiques et especes de structures. Combinatoire énumérative, pages 126--159, 1986.
[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.
[21]
David Lutterkort. Augeas: A Linux configuration API, February 2007. Available from http://augeas.net/.
[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.
[23]
Lambert Meertens. Designing constraint maintainers for user interaction, 1998. Manuscript.
[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.
[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.
[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.
[27]
Perdita Stevens. A landscape of bidirectional model transformations. Postproceedings of GTTSE, 7, 2008.
[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.
[29]
Varmo Vene. Categorical Programming with Inductive and Coinductive Types. PhD thesis, Universitatis Tartuensis, 2000.
[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.
[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.

Cited By

View all
  • (2025)Intentionally Fusing Direct Manipulations into SVG ProgramsInformation10.3390/info1603016916:3(169)Online publication date: 24-Feb-2025
  • (2025)Biparsers: Exact Printing for Data SynchronisationProceedings of the ACM on Programming Languages10.1145/37049109:POPL(2205-2231)Online publication date: 9-Jan-2025
  • (2025)Compositional Views in Compositional Images – Category: Research –Trends in Functional Programming10.1007/978-3-031-74558-4_4(75-91)Online publication date: 10-Jan-2025
  • Show More Cited By

Recommendations

Comments

Information & Contributors

Information

Published In

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
  • 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
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]

Sponsors

In-Cooperation

Publisher

Association for Computing Machinery

New York, NY, United States

Publication History

Published: 26 January 2011

Permissions

Request permissions for this article.

Check for updates

Author Tags

  1. algebra
  2. category theory
  3. lens
  4. view-update

Qualifiers

  • Research-article

Conference

POPL '11
Sponsor:

Acceptance Rates

Overall Acceptance Rate 860 of 4,328 submissions, 20%

Upcoming Conference

POPL '26

Contributors

Other Metrics

Bibliometrics & Citations

Bibliometrics

Article Metrics

  • Downloads (Last 12 months)68
  • Downloads (Last 6 weeks)5
Reflects downloads up to 05 Mar 2025

Other Metrics

Citations

Cited By

View all
  • (2025)Intentionally Fusing Direct Manipulations into SVG ProgramsInformation10.3390/info1603016916:3(169)Online publication date: 24-Feb-2025
  • (2025)Biparsers: Exact Printing for Data SynchronisationProceedings of the ACM on Programming Languages10.1145/37049109:POPL(2205-2231)Online publication date: 9-Jan-2025
  • (2025)Compositional Views in Compositional Images – Category: Research –Trends in Functional Programming10.1007/978-3-031-74558-4_4(75-91)Online publication date: 10-Jan-2025
  • (2024)Evolutionary Framework and Conflict Resolution for Multidirectional TransformationsBidirectional Collaborative Data Management10.1007/978-981-97-6429-7_2(25-36)Online publication date: 12-Dec-2024
  • (2023)Contract lenses: Reasoning about bidirectional programs via calculationJournal of Functional Programming10.1017/S095679682300005933Online publication date: 6-Nov-2023
  • (2022)Varv: Reprogrammable Interactive Software as a Declarative Data StructureProceedings of the 2022 CHI Conference on Human Factors in Computing Systems10.1145/3491102.3502064(1-20)Online publication date: 29-Apr-2022
  • (2022)Generic recursive lens combinators and their calculation lawsTheoretical Computer Science10.1016/j.tcs.2022.02.019913:C(113-137)Online publication date: 20-Apr-2022
  • (2022)Synbit: synthesizing bidirectional programs using unidirectional sketchesFormal Methods in System Design10.1007/s10703-023-00436-961:2-3(198-247)Online publication date: 1-Dec-2022
  • (2021)Synbit: synthesizing bidirectional programs using unidirectional sketchesProceedings of the ACM on Programming Languages10.1145/34854825:OOPSLA(1-31)Online publication date: 15-Oct-2021
  • (2021)DeBinelle: Semantic Patches for Coupled Database-Application Evolution2021 IEEE 37th International Conference on Data Engineering (ICDE)10.1109/ICDE51399.2021.00307(2697-2700)Online publication date: Apr-2021
  • Show More Cited By

View Options

Login options

View options

PDF

View or Download as a PDF file.

PDF

eReader

View online with eReader.

eReader

Figures

Tables

Media

Share

Share

Share this Publication link

Share on social media