Skip to content

Commit

Permalink
Merge pull request #1 from stevekrouse/API
Browse files Browse the repository at this point in the history
add API section to README
  • Loading branch information
paldepind authored Dec 25, 2018
2 parents 33036f0 + f9a6a48 commit b7ece4b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ in a purely declarative way without actually running side-effects.

* [Installation](#installation)
* [Tutorial](#tutorial)
* [API](#api)
* [Contributing](#contributing)

## Features
Expand Down Expand Up @@ -257,6 +258,40 @@ throw because our implementation passes a string to `sendMessage` that
mentions `10` instead of `5`. Therefore `testIO` will throw and our
test will fail.

## API

### `IO.of(a: A): IO<A>`

Converts any value into a IO that will return that value.

### `withEffects((...args) => A): IO<A>`

Converts an impure function into an `IO`

### `withEffectsP(p: Promise<A>): IO<A>`

Converts a Promise into an `IO`

### `throwE(error: any): IO<any>`

Once an error is `yield`ed the rest of the computation isn't being
run. The resulting `IO` value will produce an error instead of a
value.

### `catchE(errorHandler: (error: any) => IO<any>, io: IO<any>): IO<any>`

As its first argument it takes a
error function handling. As its second argument it takes an `IO`
computation. It returns a new `IO` computation.

### `testIO<A>(e: IO<A>, arr: any[], a: A): void`

The first argument to `testIO` is the IO-action to test. The second is
a list of pairs. The first element in each pair is an IO-action that
the code should attempt to perform, the second element is the value
that performing the action should return. The last argument is the
expected result of the entire computation.

## Contributing

Contributions are very welcome. Development happens as follows:
Expand Down

0 comments on commit b7ece4b

Please sign in to comment.