add some more documentation
This commit is contained in:
parent
c2b63ff779
commit
ca5185d719
1 changed files with 70 additions and 0 deletions
70
README.md
70
README.md
|
@ -24,3 +24,73 @@ result.isErr() // true
|
|||
None == None() // true
|
||||
```
|
||||
|
||||
## Documentation
|
||||
|
||||
### curry
|
||||
> (* -> a) -> (* -> a)
|
||||
|
||||
Returns a curried equivalent of the provided function.
|
||||
|
||||
```js
|
||||
import { curry } from './curry.js'
|
||||
|
||||
const add = (a, b, c) => a + b + c
|
||||
const curriedAdd = curry(add)
|
||||
const add1 = curriedAdd(1)
|
||||
const add3 = add1(2)
|
||||
const add4 = curriedAdd(2, 2)
|
||||
|
||||
const six = add3(3) // 6
|
||||
const eight = add4(2) // 7
|
||||
const twelve = curriedAdd(4, 4, 4) // 12
|
||||
```
|
||||
|
||||
### Option
|
||||
|
||||
Represents a value which may not exist.
|
||||
|
||||
#### Methods
|
||||
##### of :: Option m => m a ~> (a -> m b) -> m b
|
||||
> Option.of\<a\>(value: a) -> Option\<a\>
|
||||
|
||||
##### zero :: Option f => () -> f a
|
||||
> Option.zero\<a\>(value: a) -> Option\<a\>
|
||||
|
||||
##### chain :: Option m => m a ~> (a -> m b) -> m b
|
||||
> Option\<T\>.chain\<U\>(fn: (value: T) -> Option<U>) -> Option\<U\>
|
||||
|
||||
##### map :: Option f => f a ~> (a -> b) -> f b
|
||||
> Option\<T\>.map\<U\>(fn: (value: T) -> U) -> Option\<U\>
|
||||
|
||||
##### alt :: Option f => f a ~> f a -> f a
|
||||
> Option\<T\>.alt(other: Option\<T\>) -> Option\<T\>
|
||||
|
||||
##### fold :: Option f => f a ~> ((b, a) -> b, b) -> b
|
||||
> Option\<T\>.fold\<U\>(fn: ((acc: U, value: T) -> U, initial: U) -> U) -> U
|
||||
|
||||
### Result
|
||||
|
||||
Represents a value which may fail.
|
||||
|
||||
#### Methods
|
||||
##### of :: Result m => m a ~> (a -> m b) -> m b
|
||||
> Result.of\<a\>(value: a) -> Result\<a, ()\>
|
||||
|
||||
##### zero :: Result f => () -> f a
|
||||
> Result.zero() -> Result\<(), ()\>
|
||||
|
||||
##### chain :: Result m => m a ~> (a -> m b) -> m b
|
||||
> Result\<T, E\>.chain\<U\>(fn: (value: T) -> Result<U, E>) -> Result\<U, E\>
|
||||
|
||||
##### map :: Result f => f a ~> (a -> b) -> f b
|
||||
> Result\<T, E\>.map\<U\>(fn: (value: T) -> U) -> Result\<U, E\>
|
||||
|
||||
##### alt :: Result f => f a ~> f a -> f a
|
||||
> Result\<T, E\>.alt(other: Result\<T, E\>) -> Result\<T, E\>
|
||||
|
||||
##### fold :: Result f => f a ~> ((b, a) -> b, b) -> b
|
||||
> Result\<T, E\>.fold\<U\>(fn: ((acc: U, value: T) -> U, initial: U) -> U) -> U
|
||||
|
||||
##### bimap :: Result f => f a c ~> (a -> b, c -> d) -> f b d
|
||||
> Result\<T1, E1\>.bimap\<T2, E2\>(x: (value: T1) -> T2, y: (error: E1) -> E2) -> Result\<T2, E2\>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue