[Paper Review] Profunctor Optics, a Categorical Update
This paper generalizes profunctor optics to mixed and enriched settings using V-category theory and Tambara modules, enabling modular composition of optics across different categories. It introduces a unified framework for mixed profunctor optics with a new coend calculus-based derivation of traversals, validated through a Haskell implementation.
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.
Motivation & Objective
- To extend profunctor optics beyond unenriched, non-mixed settings to support mixed and V-enriched categories.
- To provide a categorical foundation for optics that unifies diverse access patterns like lenses, prisms, and traversals.
- To formalize the composition of heterogeneous optics (e.g., lens + prism) using a unified profunctor representation.
- To derive new families of optics, including an elementary traversal construction via coend calculus.
- To enable practical implementation in functional languages like Haskell through enriched profunctor optics.
Proposed method
- Generalizes Pastro and Street’s Tambara theory to mixed V-enriched profunctor optics using coend calculus.
- Models optics as profunctors equipped with Tambara module structures over a V-category, enabling composition across different categories.
- Introduces a new derivation of traversals using coend calculus, avoiding complex categorical machinery.
- Endows the category of mixed profunctor optics with a V-category structure, supporting enriched composition.
- Uses the Yoneda lemma and profunctor representation to encode optics as polymorphic functions.
- Provides a working Haskell implementation based on the enriched profunctor optics framework.
Experimental results
Research questions
- RQ1How can profunctor optics be generalized to mixed settings where decomposition and reconstruction directions live in different categories?
- RQ2What categorical structure supports modular composition of heterogeneous optics such as lenses and prisms?
- RQ3How can coend calculus be used to derive traversals in a principled and elementary way?
- RQ4What enriched category structure can be endowed on the category of mixed profunctor optics?
- RQ5How can this framework be implemented in a practical functional programming language like Haskell?
Key findings
- The paper successfully generalizes profunctor optics to mixed V-enriched settings, extending prior work limited to unenriched, non-mixed categories.
- It provides a new, elementary derivation of traversals using coend calculus, offering a cleaner and more principled construction than previous approaches.
- The category of mixed profunctor optics is endowed with a V-category structure, enabling enriched composition and formalizing modularity.
- The framework supports the composition of heterogeneous optics (e.g., lens + prism) via a uniform profunctor representation, enabling modular data access.
- A working Haskell implementation is provided, demonstrating the practical viability of the enriched and mixed profunctor optics model.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.