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.
Supplemental Material
- M. Abbott, T. Altenkirch, and N. Ghani. Categories of containers. In Foundations of Software Science and Computation Structures, pages 23--38. Springer, 2003. Google Scholar
Digital Library
- Michael Abbott, Thorsten Altenkirch, and Neil Ghani. Containers: constructing strictly positive types. Theor. Comput. Sci., 342(1):3--27, 2005. Google Scholar
Digital Library
- Samson Abramsky and Nikos Tzevelekos. Introduction to categories and categorical logic. In Bob Coecke, editor, New Structures for Physics. Springer, 2010.Google Scholar
Cross Ref
- 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
- 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 Scholar
Digital Library
- 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
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 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 :17, May 2007. Extended abstract in Principles of Programming Languages (POPL), 2005. Google Scholar
Digital Library
- 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 Scholar
Digital Library
- John Nathan Foster. Bidirectional Programming Languages. PhD thesis, University of Pennsylvania, December 2009.Google Scholar
Digital Library
- R. Hasegawa. Two applications of analytic functors. Theoretical Computer Science, 272(1--2):113--175, 2002. Google Scholar
Digital Library
- 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 Scholar
Cross Ref
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- 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 Scholar
Digital Library
- A. Joyal. Foncteurs analytiques et especes de structures. Combinatoire énumérative, pages 126--159, 1986.Google Scholar
- 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), 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
- 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 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
- 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
- Perdita Stevens. A landscape of bidirectional model transformations. Postproceedings of GTTSE, 7, 2008.Google Scholar
- 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 Scholar
Digital Library
- Varmo Vene. Categorical Programming with Inductive and Coinductive Types. PhD thesis, Universitatis Tartuensis, 2000.Google Scholar
- 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 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, GA, pages 164--173, 2007. Google Scholar
Digital Library
Index Terms
Symmetric lenses
Recommendations
Synthesizing symmetric lenses
Lenses are programs that can be run both "front to back" and "back to front," allowing updates to either their source or their target data to be transferred in both directions. Since their introduction by Foster et al., lenses have been extensively ...
Edit lenses
POPL '12: Proceedings of the 39th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesA 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 ...
Symmetric lenses
POPL '11: Proceedings of the 38th annual ACM SIGPLAN-SIGACT symposium on Principles of programming languagesLenses--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, ...







Comments