首页 > TAG信息列表 > Monad

范畴论记录

“一个单子(Monad)说白了不过就是自函子范畴上的一个幺半群而已,这有什么难以理解的?” 看了一点点书,终于能够理解这句话中的: Monad:这是个“函子” “自函子范畴”,勉强能够理解“自函子”和”范畴“ 幺半群:知道群,幺半群意思差不多?印象中就是群少了个零元还是什么…… 2021-08-28

Functor、Applicative 和 Monad

Functor、Applicative 和 Monad 是函数式编程语言中三个非常重要的概念,尤其是 Monad。 说明:本文中的主要代码为 Haskell 语言,它是一门纯函数式的编程语言。 一、结论 关于 Functor、Applicative 和 Monad 的概念,其实各用一句话就可以概括: 一个 Functor 就是一种实现了 Functor ty

函数式编程的形式—函数与参量、类型的关系—类型到类型间的映射

函数式编程的基本特征之一就是 类型到类型之间的映射; (T item) => (Y item)) (A, B, C) =>D map(array<T> , (T item) => (Y item)) => array<Y> moand[array<T>>]map((T item) => (Y item)) => moand[array<Y>>]   一、非monad类型函数 map(array<T>

在python里写Monad

这段时间写微信小程序看见callback hell非常炸毛,而且确实我不熟悉js的各种衍生工具(async/await, promise),想着python的coroutine是yield模改出来的,准备自己也造一个轮子。由于生成器的原理就是把一段代码挂起然后可以让调用者控制是否继续下去,这个行为和Monad非常像。Monad本身

Monad、Actor与并发编程

Haskell倡导者提出通过语言统一多线程编程和事件编程,提供一种Monad函数,其内部封装了事件和多线程抽象,无论你是哪派粉丝,都可以使用这个Monad编程。如下图:A language-based approach to unifying events and threads     这种观点得到大多数人的同意,这时被冷落一边的Scala的Actor

[Functional Programming Monad] Apply Stateful Computations To Functions (.ap, .liftA2)

When building our stateful computations, there will come a time when we’ll need to combine two or more state transactions at the same time to come up with a new result. Usually this occurs when want to use plain ol’ JavaScript functions with two or more a

[Functional Programming Monad] Combine Stateful Computations Using A State Monad

The true power of the State ADT really shows when we start combining our discrete, stateful transactions. We start looking at another construction helper named of, used to lift any given value of any type into the resultant. We also explore another instan