标签:
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]
标签:
原文地址:http://www.cnblogs.com/Answer1215/p/5863415.html