Skip to content

Commit 60b1b6f

Browse files
authored
change functor example to use Option implementation
1 parent dd949e7 commit 60b1b6f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

readme.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -461,21 +461,21 @@ is equivalent to just `object`.
461461
__Composable__
462462

463463
```js
464-
object.map(compose(f, g))
464+
object.map(x => g(f(x)))
465465
```
466466

467467
is equivalent to
468468

469469
```js
470-
object.map(g).map(f)
470+
object.map(f).map(g)
471471
```
472472

473473
(`f`, `g` are arbitrary composable functions)
474474

475-
A common functor in JavaScript is `Array` since it abides to the two functor rules:
475+
The reference implementation of [Option](#option) is a functor as it satisfies the rules:
476476

477477
```js
478-
;[1, 2, 3].map(x => x) // = [1, 2, 3]
478+
some(1).map(x => x) // = some(1)
479479
```
480480

481481
and
@@ -484,8 +484,8 @@ and
484484
const f = x => x + 1
485485
const g = x => x * 2
486486

487-
;[1, 2, 3].map(x => f(g(x))) // = [3, 5, 7]
488-
;[1, 2, 3].map(g).map(f) // = [3, 5, 7]
487+
some(1).map(x => g(f(x))) // = some(3)
488+
some(1).map(f).map(g) // = some(3)
489489
```
490490

491491
## Pointed Functor

0 commit comments

Comments
 (0)