【24h】

Composing Monads Using Coproducts

机译:使用副产物合成Monad

获取原文
获取原文并翻译 | 示例
获取外文期刊封面目录资料

摘要

Monads are a useful abstraction of computation, as they model diverse computational effects such as stateful computations, exceptions and I/O in a uniform manner. Their potential to provide both a modular semantics and a modular programming style was soon recognised. However, in general, monads proved difficult to compose and so research focused on special mechanisms for their composition such as distributive monads and monad transformers. We present a new approach to this problem which is general in that nearly all monads compose, mathematically elegant in using the standard categorical tools underpinning monads and computation-ally expressive in supporting a canonical recursion operator. In a nutshell, we propose that two monads should be composed by taking their coproduct. Although abstractly this is a simple idea, the actual construction of the coproduct of two monads is non-trivial. We outline this construction, show how to implement the coproduct within Haskell and demonstrate its usage with a few examples. We also discuss its relationship with other ways of combining monads, in particular distributive laws for monads and monad transformers.
机译:Monad是有用的计算抽象,因为它们以统一的方式对各种计算效果(例如状态计算,异常和I / O)进行建模。很快就意识到了它们提供模块化语义和模块化编程风格的潜力。但是,总的来说,单子组很难构成,因此研究主要针对其组成的特殊机制,例如分布式单子组和单子变换器。我们提出了一个解决此问题的新方法,这种方法的普遍之处在于,几乎所有monad都组成,使用支持monads的标准分类工具在数学上很优雅,并且在支持规范递归运算符方面具有计算上的表现力。简而言之,我们建议两个单子应以它们的副产物组成。尽管从抽象上讲这是一个简单的想法,但是两个单核的副产物的实际构造并不简单。我们概述了此构造,展示了如何在Haskell中实现副产品,并通过一些示例演示了其用法。我们还将讨论其与组合单子的其他方式的关系,尤其是单子和单子变压器的分配法。

著录项

相似文献

  • 外文文献
  • 中文文献
  • 专利
获取原文

客服邮箱:kefu@zhangqiaokeyan.com

京公网安备:11010802029741号 ICP备案号:京ICP备15016152号-6 六维联合信息科技 (北京) 有限公司©版权所有
  • 客服微信

  • 服务号