Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improved definition of pointed functor #229

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -495,14 +495,18 @@ some(1).map(f).map(g) // = some(3)
```

## Pointed Functor
An object with an `of` function that puts _any_ single value into it.
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.

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

```js
Array.of(1) // [1]

Array.of(1).map(add(1)) // [2]
```

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

## Lift

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.
Expand Down