论文标题

分配器光学和遍历

Profunctor optics and traversals

论文作者

Román, Mario

论文摘要

光学是数据结构的双向登录器;它们提供了许多常见数据转换的强大抽象。该抽象是组成的,这要归功于具有代数结构的分配器的表示,称为tambara模块。在均基础上进行了一些基本应用之后,在每个基本光学器件中都有一个基本应用后,就存在了视位的一般定义。遍历曾经是例外;我们展示了遍历的基本推导,并讨论了光学的其他一些新推导。我们将遍历的表征与以前的遍历联系起来,表明代表并分成形状的ComoNAD的结膜是可遍历的函数。在分配器方面,光学的表示在文献中有许多不同的证据。我们讨论了两种证明这一点的方法,将两者都推广到混合光学的情况下采取任意行动。光学类别可以看作是帕斯特罗(Pastro)和街(Pastro)和街(Street)描述的单元的Eilenberg-Moore类别。这为我们提供了不同家族分配光学之间组成的两种不同的方法:使用定义它们的单子之间的分布定律,并使用单调的共同生物。第二个是在Haskell编程中隐式使用的一个。但是我们表明,为了忠实地对其进行建模,需要对光学概念进行改进。我们提供了haskell和部分AGDA代表定理中光学库的实验实现。

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.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源