Skip to content

Commit 6d30175

Browse files
committed
improved definition of pointed functor
1 parent 69d1b25 commit 6d30175

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

readme.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -495,14 +495,18 @@ some(1).map(f).map(g) // = some(3)
495495
```
496496

497497
## Pointed Functor
498-
An object with an `of` function that puts _any_ single value into it.
498+
An object that is a [Functor](#functor) that can be created from _any_ value. A pointed functor can be seen as a container that can wrap something of any type by [lifting](#lift) that value into it.
499499

500-
ES2015 adds `Array.of` making arrays a pointed functor.
500+
Since JS arrays are functors (have a `.map` method) and have an `Array.of()` function they are pointed functors!
501501

502502
```js
503503
Array.of(1) // [1]
504+
505+
Array.of(1).map(add(1)) // [2]
504506
```
505507

508+
This `of` function is an important requirement for satisfying the [Monad](#monad) interface where it is an example of a [Kleisli Arrow](#kleisi-composition).
509+
506510
## Lift
507511

508512
Lifting is when you take a value and put it into an object like a [functor](#pointed-functor). If you lift a function into an [Applicative Functor](#applicative-functor) then you can make it work on values that are also in that functor.

0 commit comments

Comments
 (0)