add Homomorphism

This commit is contained in:
Steve Mao 2017-04-16 09:06:54 +10:00
parent 72fe6956aa
commit 1d15590eba
No known key found for this signature in database
GPG key ID: EED733AB250010C0

View file

@ -51,6 +51,7 @@ __Table of Contents__
* [Morphism](#morphism)
* [Endomorphism](#endomorphism)
* [Isomorphism](#isomorphism)
* [Homomorphism](#homomorphism)
* [Catamorphism](#catamorphism)
* [Anamorphism](#anamorphism)
* [Hylomorphism](#hylomorphism)
@ -696,6 +697,16 @@ coordsToPair(pairToCoords([1, 2])) // [1, 2]
pairToCoords(coordsToPair({x: 1, y: 2})) // {x: 1, y: 2}
```
### Homomorphism
A homomorphism is just a structure preserving map. In fact, a functor is just a homomorphism between categories as it preserves the original category's structure under the mapping.
```js
A.of(f).ap(A.of(x)) == A.of(f(x))
Either.of(_.toUpper).ap(Either.of("oreos")) == Either.of(_.toUpper("oreos"))
```
### Catamorphism
A `reduceRight` function that applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.