Skip to main content

What You Needa Know About Yoneda: Profunctor Optics and the Yoneda Lemma

Guillaume Boisseau and Jeremy Gibbons

Abstract

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.

Journal
PACMPL
Month
September
Note
Functional Pearl
Number
ICFP
Volume
2
Year
2018