打破计算效应之间的单子-共单子对称性
Breaking a monad-comonad symmetry between computational effects
摘要:
计算效应通常可以在单子的Kleisli范畴或共单子的coKleisli范畴中解释。monads和comonads之间的二元性一般对应于构造和观察之间的对称性,例如在提出异常和查找状态之间。由于附加的性质,我们可以更进一步:monad的coKleisli-on-Kleisli范畴提供了关于给定构造的一种观察,而comonad的Kleisli-on-coKleisli范畴对偶地提供了关于给定观察的一种构造。在前面的示例中,这会导致捕获异常并更新状态。然而,计算效应的解释通常是基于一个不是自对偶的范畴,如集合范畴。这导致了单子-共单子二元性的打破。例如,在分配范畴中,状态效应比例外效应具有更好的性质。这句话为处理异常的常用机制提供了一个新的观点。本文的目的是建立一个等式的异常处理语义的基础上coKleisli-on-Kleisli类别的单子异常。我们专注于n元函数和条件。我们提出了一个程序员的语言异常,我们证明,它具有所需的行为,n元函数和条件。
英文摘要:
Computational effects may often be interpreted in the Kleisli category of a monad or in the coKleisli category of a comonad. The duality between monads and comonads corresponds, in general, to a symmetry between construction and observation, for instance between raising an exception and looking up a state. Thanks to the properties of adjunction one may go one step further: the coKleisli-on-Kleisli category of a monad provides a kind of observation with respect to a given construction, while dually the Kleisli-on-coKleisli category of a comonad provides a kind of construction with respect to a given observation. In the previous examples this gives rise to catching an exception and updating a state. However, the interpretation of computational effects is usually based on a category which is not self-dual, like the category of sets. This leads to a breaking of the monad-comonad duality. For instance, in a distributive category the state effect has much better properties than the exception effect. This remark provides a novel point of view on the usual mechanism for handling exceptions. The aim of this paper is to build an equational semantics for handling exceptions based on the coKleisli-on-Kleisli category of the monad of exceptions. We focus on n-ary functions and conditionals. We propose a programmer's language for exceptions and we prove that it has the required behaviour with respect to n-ary functions and conditionals.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。