HackerPapers

arXiv:2001.07488cs.PL

Profunctor Optics, a Categorical Update

Bryce Clarke, Derek Elkins, Jeremy Gibbons, Fosco Loregian, Bartosz Milewski, Emily Pillmore, Mario Román

Abstract

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.

arXiv comments
38 pages. Final version with Compositionality metadata, does not change theorem numbering
Journal reference
Compositionality, Volume 6 (2024) (February 23, 2024) compositionality:13530
DOI
doi:10.32408/compositionality-6-1
Subjects
cs.PLProgramming Languages math.CTCategory Theory

On Hacker News

Linked by 3 identifiable commenters in 3 comments across 3 threads, from Feb 2020 to Nov 2022. Found in 1 HN submission from Jan 2020 to Jan 2020. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments3 threads

    • Apologies for the jargon, but there isn't room in a comment box for a detailed explanation. "The Essence of the Iterator Pattern"[0] posed an open problem in type theory as to whether or not "lawful traversals", of type `∀ F:Applicative. (X -> F X) -> (B -> F B)` could appear…

      rssoconnorView on HNParent context

  1. Lenses 1 comment
    • There are infinitely many, so all is out, but the standard ones are covered here: https://oleg.fi/gists/posts/2017-04-18-glassery.html Page 10 of this paper has a table with references to some more exotic optics, though it's going to be hard to parse without some category…

      hither_shoresView on HNParent context

  2. Math is an insurance policy 1 comment
    • Plenty of serious researchers in top universities are studying the intersection of mathematics and functional programming, and I don't think that they're somehow not 'real mathematicians'. Here's a paper by the author of this post, formalising a popular Haskell pattern in…

      dddbbbView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.