Skip to content

Commit

Permalink
Adds Identity API to docs (#38)
Browse files Browse the repository at this point in the history
* Add API documentation
  • Loading branch information
Ryan Stegmann authored and evilsoft committed Feb 10, 2017
1 parent 7a4ba53 commit 6674ae9
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
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

.npmignore
.babelrc
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)`

0 comments on commit 6674ae9

Please sign in to comment.