Profunctor optics and traversals

01/22/2020
by   Mario Román, et al.
0

Optics are bidirectional accessors of data structures; they provide a powerful abstraction of many common data transformations. This abstraction is compositional thanks to a representation in terms of profunctors endowed with an algebraic structure called Tambara module. There exists a general definition of optic in terms of coends that, after some elementary application of the Yoneda lemma, particularizes in each one of the basic optics. Traversals used to be the exception; we show an elementary derivation of traversals and discuss some other new derivations for optics. We relate our characterization of traversals to the previous ones showing that the coalgebras of a comonad that represents and split into shape and contents are traversable functors. The representation of optics in terms of profunctors has many different proofs in the literature; we discuss two ways of proving it, generalizing both to the case of mixed optics for an arbitrary action. Categories of optics can be seen as Eilenberg-Moore categories for a monad described by Pastro and Street. This gives us two different approaches to composition between profunctor optics of different families: using distributive laws between the monads defining them, and using coproducts of monads. The second one is the one implicitly used in Haskell programming; but we show that a refinement of the notion of optic is required in order to model it faithfully. We provide experimental implementations of a library of optics in Haskell and partial Agda formalizations of the profunctor representation theorem.

READ FULL TEXT

page 1

page 2

page 3

page 4

research
01/21/2020

Profunctor optics, a categorical update

Profunctor optics are bidirectional data accessors that capture data tra...
research
01/27/2020

Understanding Profunctor Optics: a representation theorem

Optics, aka functional references, are classes of tools that allow compo...
research
06/15/2021

On Doctrines and Cartesian Bicategories

We study the relationship between cartesian bicategories and a specialis...
research
10/21/2019

Computability in partial combinatory algebras

We prove a number of elementary facts about computability in partial com...
research
04/20/2022

Dependent Optics

A wide variety of bidirectional data accessors, ranging from mixed optic...
research
12/20/2022

Pragmatic isomorphism proofs between Coq representations: application to lambda-term families

There are several ways to formally represent families of data, such as l...
research
10/05/2021

Unifying AI Algorithms with Probabilistic Programming using Implicitly Defined Representations

We introduce Scruff, a new framework for developing AI systems using pro...

Please sign up or login with your details

Forgot password? Click here to reset