mirror of
https://github.com/rjNemo/functional-programming-jargon
synced 2026-06-12 05:26:43 +00:00
Added basic description of semigroup. Fixed comonad
This commit is contained in:
parent
6913df8f93
commit
ed415a1003
1 changed files with 9 additions and 3 deletions
12
readme.md
12
readme.md
|
|
@ -65,7 +65,7 @@ partial(2); //=> 42
|
||||||
> The process of converting a function with multiple arity into the same function with an arity of one. Not to be confused with partial application, which can produce a function with an arity greater than one.
|
> The process of converting a function with multiple arity into the same function with an arity of one. Not to be confused with partial application, which can produce a function with an arity greater than one.
|
||||||
|
|
||||||
```js
|
```js
|
||||||
let sum = (a,b) => a+b;
|
let sum = (a, b) => a + b;
|
||||||
|
|
||||||
let curriedSum = (a) => (b) => a + b;
|
let curriedSum = (a) => (b) => a + b;
|
||||||
|
|
||||||
|
|
@ -321,9 +321,9 @@ Extract takes a value out of a container. Essentially it's the opposite of `of`.
|
||||||
CoIdentity(1).extract() // 1
|
CoIdentity(1).extract() // 1
|
||||||
```
|
```
|
||||||
|
|
||||||
Extend runs a function on the comonad. The function should return the same type as the value in the Comonad. It's the opposite of `chain`.
|
Extend runs a function on the comonad. The function should return the same type as the Comonad.
|
||||||
```js
|
```js
|
||||||
CoIdentity(1).extend(co => co.extract() + 1) // 2
|
CoIdentity(1).extend(co => co.extract() + 1) // CoIdentity(2)
|
||||||
```
|
```
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
@ -384,6 +384,12 @@ Array.prototype.equals = arr => {
|
||||||
|
|
||||||
## Semigroup
|
## Semigroup
|
||||||
|
|
||||||
|
An object that has a `concat` function that combines it with another object of the same type.
|
||||||
|
|
||||||
|
```js
|
||||||
|
[1].concat([2]) // [1, 2]
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## Foldable
|
## Foldable
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue