函子之于透镜如同函子之于双板:介绍多板
Functor is to Lens as Applicative is to Biplate: Introducing Multiplate
摘要:
本文给出了透镜的两个新的范畴刻画:一个是作为余代数的余代数,另一个是作为某类余代数范畴上的monoidal自然变换。第一个特征化的store comonad可以推广为笛卡尔store comonad,并且这个笛卡尔store comonad的余代数恰好是Uniplate通用编程库的Biplates。另一方面,函子上的monoidal自然变换可以推广到一类更特殊的余代数上。这个泛化结果是来自Compos泛型编程库的compos类型。最初由van Laarhoven提出的一个定理证明了这两种推广是同构的,因此支持单一递归类型上的泛型程序的Uniplate和Compos库的核心数据类型是相同的。Uniplate和Compos库都将此核心功能泛化为以不同方式支持相互递归的类型。本文提出了第三个扩展来支持相互递归的数据类型,它与Compos一样强大,也与Unipate一样易于使用。这个被称为Multiplate的提议,除了Haskell的普通类型类机制之外,只需要秩3多态性。
英文摘要:
This paper gives two new categorical characterisations of lenses: one as a coalgebra of the store comonad, and the other as a monoidal natural transformation on a category of a certain class of coalgebras. The store comonad of the first characterisation can be generalized to a Cartesian store comonad, and the coalgebras of this Cartesian store comonad turn out to be exactly the Biplates of the Uniplate generic programming library. On the other hand, the monoidal natural transformations on functors can be generalized to work on a category of more specific coalgebras. This generalization turns out to be the type of compos from the Compos generic programming library. A theorem, originally conjectured by van Laarhoven, proves that these two generalizations are isomorphic, thus the core data types of the Uniplate and Compos libraries supporting generic program on single recursive types are the same. Both the Uniplate and Compos libraries generalize this core functionality to support mutually recursive types in different ways. This paper proposes a third extension to support mutually recursive data types that is as powerful as Compos and as easy to use as Uniplate. This proposal, called Multiplate, only requires rank 3 polymorphism in addition to the normal type class mechanism of Haskell.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。