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

Adds Identity API to docs #38

Merged
merged 9 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
test
*.spec.js
docs

.travis.yml
.jshintignore
Expand Down
78 changes: 78 additions & 0 deletions docs/crocks/Identity.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Identity

`Identity a`

Crock which returns the same value that was used as its argument

"`Identity`" creates linear data flow in comparison to imperative usage.

```js
// Imperative flow
const capitalizeFirstLetter = string => {
const firstLetter = string.charAt(0)
const upppercasedLetter = firstLetter.toUpperCase()
return upppercasedLetter + string.slice(1);
}

// Declarative flow
const capitalizeFirstLetter = string =>
Identity(string)
.map(str => str.charAt(0))
.map(char => char.toUpperCase())
.map(upper => upper + string.slice(1))
.value()
```

`Identity` exposes these constructors and instances:

| Constructor | Instance |
|:---|:---|
| [`of`](#of) | [`inspect`](#inspect), [`value`](#value), [`type`](#type), [`equals`](#equals), [`map`](#map), [`ap`](#ap), [`of`](#of), [`chain`](#chain), [`sequence`](#sequence), [`traverse`](#traverse) |

## Constructors

### of

`Identity m => a -> m a`

## Instances

### inspect

`() => String`

### value

`Identity m => m a ~> () => a`

### type

`() -> String`

### equals

`a -> Boolean`

### map

`Identity m => m a ~> (a -> b) -> m b`

### ap

`Identity m => m (a -> b) ~> m a -> m b`

### of

`Identity m => a -> m a`

### chain

`Identity m => m a ~> (a -> m b) -> m b`

### sequence

`Identity m, Applicative f => m (f a) ~> (b -> f b) -> f (m a)`

### traverse

`Identity m, Applicative f => m a ~> (c -> f c) -> (a -> f b) -> f (m b)`