【文件属性】:
文件名称:data.monad:单子结构
文件大小:7KB
文件格式:ZIP
更新时间:2021-05-15 04:26:43
JavaScript
data.monad
描述
javascript monad结构。
类型签名
界面。
interface M < T> {
// return
function unit < T> (value: T): M < T> {
}
// >>=
function bind < T> (instance: M < T> , transform: (value: T) = > M < U> ): M < U> {
}
}
绑定(单位(x),f)== f(x)
绑定(米,单位)==米
bind(bind(m,f),g)== bind(m,x => bind(f(x),g))
用法
身份
new Identity ( 5 ) . bind ( x =>
new Identity ( 6 ) . bind ( x2
【文件预览】:
data.monad-master
----src()
--------identity.js(281B)
--------prelude.js(241B)
--------maybe.js(2KB)
--------index.js(189B)
--------promise.js(64B)
----.travis.yml(73B)
----test()
--------identity_test.js(505B)
--------index_test.js(191B)
--------maybe_test.js(4KB)
--------prelude_test.js(2KB)
----README.md(2KB)
----.gitignore(1KB)
----package.json(856B)