Profunctor Optics, a Categorical Update
Bryce Clarke, Derek Elkins, Jeremy Gibbons, Fosco Loregian, Bartosz Milewski, Emily Pillmore, Mario Román
TL;DR
This work generalizes profunctor optics to enriched and mixed settings, unifying lenses, prisms, traversals and related patterns under a single coend-based definition. It extends Pastro-Street Tambara theory to enable generalized Tambara modules for two independent monoidal actions, yielding an enriched category of mixed optics and a profunctor representation theorem that justifies composing optics as ordinary function composition. The paper also presents new optics (e.g., algebraic lenses, glasses) and elementary derivations (e.g., traversals via power-series functors), plus a Haskell implementation that materializes the framework for practical programming. By connecting coend calculus, Tambara modules, and the Double Yoneda lemma, the approach provides a principled, modular architecture for building and composing optics in functional programming with enriched categories. The results offer a robust foundation for future work on lawfulness, Kan extensions, and library design for optics in real-world languages.
Abstract
Optics are bidirectional data accessors that capture data transformation patterns such as accessing subfields or iterating over containers. Profunctor optics are a particular choice of representation supporting modularity, meaning that we can construct accessors for complex structures by combining simpler ones. Profunctor optics have previously been studied only in an unenriched and non-mixed setting, in which both directions of access are modelled in the same category. However, functional programming languages are arguably better described by enriched categories; and we have found that some structures in the literature are actually mixed optics, with access directions modelled in different categories. Our work generalizes a classic result by Pastro and Street on Tambara theory and uses it to describe mixed V-enriched profunctor optics and to endow them with V-category structure. We provide some original families of optics and derivations, including an elementary one for traversals. Finally, we discuss a Haskell implementation.
