## Symmetric Lenses

Citations: | 16 - 1 self |

### BibTeX

@MISC{Hofmann_symmetriclenses,

author = {Martin Hofmann and Benjamin Pierce and Daniel Wagner},

title = {Symmetric Lenses},

year = {}

}

### OpenURL

### 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 studied from a more fundamental 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. 1.

### Citations

64 | Relational lenses: a language for updatable views - Bohannon, Pierce, et al. - 2006 |

63 |
Containers - constructing strictly positive types
- Abbott, Altenkirch, et al.
(Show Context)
Citation Context ...sublens to all the elements of some data structure (Section 8). This technique applies not only to algebraic data structures but to an arbitrary container in the sense of Abbot, Altenkirch, and Ghani =-=[2]-=-. This extends the variety of list and tree mapping combinators that we can construct from first principles to include non-inductive datatypes such as labeled dags and graphs. We carry out these inves... |

46 | A.: Boomerang: resourceful lenses for string data
- Bohannon, Foster, et al.
- 2008
(Show Context)
Citation Context ...es is the framework of lenses introduced in [11]. Prior work on lenses and lens-like structures has mostly been carried out in specific domains—designing combinators for lenses that work over strings =-=[5, 7, 12]-=-, trees [11, 17, 20, 25], relations [6], graphs [16], or software models [9, 10, 15, 26, 27, 30]. By contrast, our aim in this paper is to advance the foundations of lenses in two significant respects... |

40 | Categories of containers
- Abbott, Altenkirch, et al.
- 2003
(Show Context)
Citation Context ...tion for a variety of operations on datatypes built from polynomial functors. Narrowing the focus to the very common “map” operation, we can generalize still further, to any kind of container functor =-=[1]-=-, i.e. a normal functor in the terminology of Hasegawa [14] or an analytic functor in the terminology of Joyal [19]. (These structures are also related to the shapely types of Jay and Cockett [18].) 8... |

17 |
Algebraic models for bidirectional model synchronization
- Diskin
- 2008
(Show Context)
Citation Context ...e structures has mostly been carried out in specific domains—designing combinators for lenses that work over strings [5, 7, 12], trees [11, 17, 20, 25], relations [6], graphs [16], or software models =-=[9, 10, 15, 26, 27, 30]-=-. By contrast, our aim in this paper is to advance the foundations of lenses in two significant respects. First, we show that lenses can be generalized from their usual asymmetric presentation—where o... |

13 | Matching lenses: alignment and view update
- Barbosa, Cretin, et al.
- 2010
(Show Context)
Citation Context ...es is the framework of lenses introduced in [12]. Prior work on lenses and lens-like structures has mostly been carried out in specific domains—designing combinators for lenses that work over strings =-=[5, 7, 13, 14]-=-, trees [12, 20, 23, 28], relations [6], graphs [19], or software models [9–11, 17, 18, 29, 30, 33]. By contrast, our aim in this paper is to advance the foundations of lenses in two significant respe... |

7 | M.: Model-versioning-in-the-large: Algebraic foundations and the tile notation
- Diskin, Czarnecki, et al.
- 2009
(Show Context)
Citation Context ...e structures has mostly been carried out in specific domains—designing combinators for lenses that work over strings [5, 7, 12], trees [11, 17, 20, 25], relations [6], graphs [16], or software models =-=[9, 10, 15, 26, 27, 30]-=-. By contrast, our aim in this paper is to advance the foundations of lenses in two significant respects. First, we show that lenses can be generalized from their usual asymmetric presentation—where o... |

3 |
Abramsky and Nikos Tzevelekos. Introduction to Categories and Categorical Logic
- Samson
- 2011
(Show Context)
Citation Context ...iag; (π1 ⊗ π2) = id (6) for all arrows f and g. Building a categorical product from a tensor product is not the most familiar presentation, but it can be shown to be equivalent (see Proposition 13 in =-=[3]-=-, for example). In the category LENS, we can build a tensor product and can also build projection lenses with reasonable behaviors. However, these projections are not quite natural transformations—law... |

1 |
Matching lenses: Alignment and view up11 2010/7/16
- Barbosa, Cretin, et al.
- 2010
(Show Context)
Citation Context ...es is the framework of lenses introduced in [11]. Prior work on lenses and lens-like structures has mostly been carried out in specific domains—designing combinators for lenses that work over strings =-=[5, 7, 12]-=-, trees [11, 17, 20, 25], relations [6], graphs [16], or software models [9, 10, 15, 26, 27, 30]. By contrast, our aim in this paper is to advance the foundations of lenses in two significant respects... |