Reference. Profunctor Optics: Modular Data Accessors
Cite
Cited by (8)
On a fibrational construction for optics, lenses, and Dialectica categories capucci-2024-onx
Categories of lenses/optics and Dialectica categories are both comprised of bidirectional morphisms of basically the same form. In this work we show how they can be considered a special case of an overarching fibrational construction, generalizing Hofstra’s construction of Dialectica fibrations and Spivak’s construction of generalized lenses. This construction turns a tower of Grothendieck fibrations into another tower of fibrations by iteratively twisting each of the components, using the opposite fibration construction.
Profunctor Optics, a Categorical Update clarke-2024-profunctor
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.
Fundamental Components of Deep Learning: A category-theoretic approach gavranovicFundamentalComponentsDeep
Deep learning, despite its remarkable achievements, is still a young field. Like the early stages of many scientific disciplines, it is marked by the discovery of new phenomena, ad-hoc design decisions, and the lack of a uniform and compositional mathematical foundation. From the intricacies of the implementation of backpropagation, through a growing zoo of neural network architectures, to the new and poorly understood phenomena such as double descent, scaling laws or in-context learning, there are few unifying principles in deep learning. This thesis develops a novel mathematical foundation for deep learning based on the language of category theory. We develop a new framework that is a) end-to-end, b) unform, and c) not merely descriptive, but prescriptive, meaning it is amenable to direct implementation in programming languages with sufficient features. We also systematise many existing approaches, placing many existing constructions and concepts from the literature under the same umbrella. In Part I we identify and model two main properties of deep learning systems parametricity and bidirectionality by we expand on the previously defined construction of actegories and Para to study the former, and define weighted optics to study the latter. Combining them yields parametric weighted optics, a categorical model of artificial neural networks, and more. Part II justifies the abstractions from Part I, applying them to model backpropagation, architectures, and supervised learning. We provide a lens-theoretic axiomatisation of differentiation, covering not just smooth spaces, but discrete settings of boolean circuits as well. We survey existing, and develop new categorical models of neural network architectures. We formalise the notion of optimisers and lastly, combine all the existing concepts together, providing a uniform and compositional framework for supervised learning.
The Game Semantics of Game Theory hedges-2023-the
Fibre optics braithwaite-2021-fibre
Lenses, optics and dependent lenses (or equivalently morphisms of containers, or equivalently natural transformations of polynomial functors) are all widely used in applied category theory as models of bidirectional processes. From the definition of lenses over a finite product category, optics weaken the required structure to actions of monoidal categories, and dependent lenses make use of the additional property of finite completeness (or, in case of polynomials, even local cartesian closure). This has caused a split in the applied category theory literature between those using optics and those using dependent lenses. The goal of this paper is to unify optics with dependent lenses, by finding a definition of fibre optics admitting both as special cases.
Morphisms of Open Games hedges-2018-morphisms
What you needa know about Yoneda: profunctor optics and the Yoneda lemma (functional pearl) boisseau-2018-what
Profunctor optics are a neat and composable representation of bidirectional data accessors, including lenses, and their dual, prisms. The profunctor representation exploits higher-order functions and higher-kinded type constructor classes, but the relationship between this and the familiar representation in terms of “getter” and “setter” functions is not at all obvious. We derive the profunctor representation from the concrete representation, making the relationship clear. It turns out to be a fairly direct application of the Yoneda Lemma, arguably the most important result in category theory. We hope this derivation aids understanding of the profunctor representation. Conversely, it might also serve to provide some insight into the Yoneda Lemma.
Compositional Game Theory ghani-2018-compositional
Cites 36 works (3 here)
With notes (3)
The essence of the Iterator pattern gibbons-2009-the
The Iterator pattern gives a clean interface for element-by-element access to a collection, independent of the collection’s shape. Imperative iterations using the pattern have two simultaneous aspects: mapping and accumulating . Various existing functional models of iteration capture one or other of these aspects, but not both simultaneously. We argue that C. McBride and R. Paterson’s applicative functors (Applicative programming with effects, J. Funct. Program. , 18 (1): 1–13, 2008), and in particular the corresponding traverse operator, do exactly this, and therefore capture the essence of the Iterator pattern. Moreover, they do so in a way that nicely supports modular programming. We present some axioms for traversal, discuss modularity concerns and illustrate with a simple example, the wordcount problem.
Applicative programming with effects mcbride-2008-applicative
In this article, we introduce Applicative functors – an abstract characterisation of an applicative style of effectful programming, weaker than Monads and hence more widespread. Indeed, it is the ubiquity of this programming pattern that drew us to the abstraction. We retrace our steps in this article, introducing the applicative pattern by diverse examples, then abstracting it to define the Applicative type class and introducing a bracket notation that interprets the normal application syntax in the idiom of an Applicative functor. Furthermore, we develop the properties of applicative functors and the generic operations they support. We close by identifying the categorical structure of applicative functors and examining their relationship both with Monads and with Arrow.
Datatype-Generic Programming gibbons-2007-datatype
External (33)
- cats library, v0.9.0 (2017)
- Profunctor Optics: Modular Data Accessors (accompanying code) (2017)
- Monocle library, v1.4.0 (2017)
- Pattern synonyms (2016)
- optics-0.0.2 library (2016)
- Profunctor Optics: Making Sense of Data Accessors (undergraduate thesis, University of Oxford) (2016)
- Applicative bidirectional programming with lenses (2015)
- ProfunctorLens.js snippet (2015)
- Strong Profunctor Law (2015)
- A representation theorem for second-order functionals (2014)
- Understanding idiomatic traversals backwards and forwards (2013)
- Comments on Simon Peyton Jones’ talk about lenses at Haskell eXchange (2013)
- Functor is to Lens as Applicative is to Biplate: Introducing Multiplate (2011)
- A Non-Regular Data Type Challenge (2009)
- CPS-Based Functional References (2009)
- A pattern for almost compositional functions (2008)
- Free Theorems Involving Type Constructor Classes (2008)
- Uniform boilerplate and list processing (2007)
- Matching Objects with Patterns (2007)
- Combinators for bi-directional tree transformations: a linguistic approach to the view update problem (2005)
- Scrap your boilerplate: a practical design pattern for generic programming (2003)
- Haskell 98 language and libraries : the revised report (2003)
- First Class Patterns (2000)
- Fundamental Concepts in Programming Languages (2000)
- Nested datatypes (1998)
- Compositional references for stateful functional programming (1997)
- Monads for functional programming (1993)
- Theorems for free! (1989)
- Type Algebras, Functor Categories, and Block Structure (1986)
- Update semantics of relational views (1981)
- purescript-profunctor-lenses-2.2.0 library
- lens-4.15.1 library
- mezzolens-0.0.0 library