arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2401.14286cs.PLcs.LO
收藏

Applicative 函子与 Multifunctor 的等价性

Equivalence of Applicative Functors and Multifunctors

Andreas Abel

AI总结:

本文通过相互推导 Applicative 函子与 multifunctor 表述下的定律,严格证明二者等价,并将 Applicative 定律简化为统一的 multifunctor 复合方案。

摘要:

McBride 和 Paterson 将 Applicative 函子引入 Haskell,它们等价于范畴论中的(带强度的)lax monoidal 函子。Applicative 函子 F 通过惯用应用 \\_\circledast\\_ : F (A \to B) \to F A \to F B 以及一组有些难以记忆的定律来表述。Capriotti 和 Kaposi 观察到,applicative 函子可以被构想为 multifunctor,即由一族类似 zipWith 的函数 liftA_n : (A_1 \to ... \to A_n \to C) \to F A_1 \to ... \to F A_n \to F C 表示,这些函数推广了 pure(n=0)、fmap(n=1)和 liftA2(n=2)。这将相关定律简化为仅有第一条函子定律,以及一个统一的第二(多)函子定律模式,即 liftA 的复合定律。在本札记中,我们通过相互推导它们的定律,严格证明 applicative 函子事实上等价于 multifunctor。

英文摘要:

McBride and Paterson introduced Applicative functors to Haskell, which are equivalent to the lax monoidal functors (with strength) of category theory. Applicative functors F are presented via idiomatic application $\_\circledast\_ : F (A \to B) \to F A \to F B$ and laws that are a bit hard to remember. Capriotti and Kaposi observed that applicative functors can be conceived as multifunctors, i.e., by a family liftA$_n$ : $(A_1 \to ... \to A_n \to C) \to F A_1 \to ... \to F A_n \to F C$ of zipWith-like functions that generalize pure $(n=0)$, fmap $(n=1)$ and liftA2 $(n=2)$. This reduces the associated laws to just the first functor law and a uniform scheme of second (multi)functor laws, i.e., a composition law for liftA. In this note, we rigorously prove that applicative functors are in fact equivalent to multifunctors, by interderiving their laws.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑