-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add API documentation
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
node_modules | ||
test | ||
*.spec.js | ||
docs | ||
|
||
.npmignore | ||
.babelrc | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)` |