计算机科学 ›› 2011, Vol. 38 ›› Issue (7): 144-147.

• 软件工程 • 上一篇    下一篇

Comonads理论及其在函数式程序语言Haskell中的应用

苏锦钿,余珊珊   

  1. (华南理工大学计算机科学与工程学院 广州510640);(中山大学信息科学与技术学院 广州510275)
  • 出版日期:2018-11-16 发布日期:2018-11-16
  • 基金资助:
    本文受2010年高校博上点科研基金一新教师类(20100172120043),华南理工大学中央高校基本科研业务费专项资金(2009ZM0158)资助。

Comonad Theory and its Applications in Functional Programming Language Haskell

SU Jin-dian,YU Shan-shan   

  • Online:2018-11-16 Published:2018-11-16

摘要: 函数式程序语言Haskell中的Monads理论在描述上下文依赖计算等方面存在一定的不足。作为Monads的范畴论对偶概念,Comonads理论可以有效地提高Haskell对上下文依赖计算的描述能力。首先给出Comonads的范畴论定义和性质,以及Comonads在Haskell的具体实现;接着探讨Comonads的CoKleisfi三元组和CoKleisli范畴,通过实例说明如何将其应用于上下文依赖计算的描述和推理中;最后进一步研究Comonads与Monads之间的分配律,指出如何通过分配律将效果计算与上下文依赖计算有机地融合起来。

关键词: Comonads,函数式程序语言,Haskell,上下文依赖计算,范畴论

Abstract: Monad theory in functional programming language Haskell has some disadvantages in describing the context dependent computations. As the categorical dual notion of monads, comonad theory can effectively improve Haskell's description ability of context-dependent computations. Firstly, we gave the categorical definitions and properties of Comonads, as well as their implementations in Haskell. Secondly, we discussed the CoKleisli triple and CoKleisli category, and used some examples to demonstrate how to apply them into the descriptions and reasoning of context dependent computations. Finally, we also discussed the distributive laws between Comonads and Monads, and showed its uses in merging the effectful computations and context dependent computations.

Key words: Comonads,Functional programming,Haskcll,Context dependent computations,Category theory

No related articles found!
Viewed
Full text


Abstract

Cited

  Shared   
  Discussed   
No Suggested Reading articles found!