首页 > 代码库 > [Javascript] Functor law
[Javascript] Functor law
Functor laws:
1. Identity:
map(id) == id
2. Composition:
compose(map(f), map(g)) == map(compose(f,g))
compose( map(toUpper), map(reverse), toArray )("bingo");compose( map( compose(toUpper reverse), toArray ))("bingo")
Natural Transformations:
"Takes one functor to another without knowing anything about the value".
maybeToArray(Maybe(2)) // [2]maybeToArray(Maybe(null)) // []
compose(nt, map(f)) == compose(map(f), nt)compose(maybeToArray, map(add(1)))(Maybe(5)) //[6]compose(map(add(1)), maybeToArray)(Maybe(5)) // [6]
[Javascript] Functor law
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。