TGViewer
dd if=/dev/stuff of=/dev/tg dd if=/dev/stuff of=/dev/tg @randomstuffilike · 2.48K subscribers
Post #553 3.85K

Forwarded from Nick Ivanych

Profunctor optics and traversals
Mario Román
https://arxiv.org/abs/2001.08045
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.
#paper
More from @randomstuffilike
  1. Mar 13, 2026Задолбался, что приходится быть chief software sloperator на работе, поэтому в терапевтиче…
  2. Feb 28, 2024Моделирование доменных типов на расте: https://mmapped.blog/posts/25-domain-types.html
  3. Dec 5, 2023Слайды доклада Томаса Микулы «Monads Are Not About Sequencing»: https://continuously.dev/p…
  4. Nov 9, 2023Design Guidelines for Domain-Specific Languages Очень хороший пейпер, предлагающий 26 гайд…
  5. Oct 19, 2023И чуть более развернутый пост от автора: https://zackoverflow.dev/writing/flappy-bird-in-t…
  6. Oct 19, 2023https://twitter.com/zack_overflow/status/1715042340514017559 — Flappy Bird на тайплевеле т…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →