WG211/M18Gibbons2
Profunctor Optics and the Yoneda Lemma by Jeremy Gibbons (based on joint work with Guillaume Boisseau)
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; the relationship between this and the more 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 serves to provide some insight into the Yoneda Lemma (which we will explain as we go along).