Skip to content

Commit

Permalink
version 2.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gcanti committed May 14, 2020
1 parent 088aab8 commit 977bcd2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
13 changes: 12 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
**Note**: Gaps between patch versions are faulty/broken releases. **Note**: A feature tagged as Experimental is in a
high state of flux, you're at risk of it changing without notice.

# 2.6.0
# 2.6.1

- **New Feature**
- add W variants, closes #904 (@gcanti)
Expand All @@ -30,21 +30,32 @@ high state of flux, you're at risk of it changing without notice.
- `IOEither`
- add `getOrElseW` (@gcanti)
- add `chainW` (@gcanti)
- add `chainEitherKW` (@giogonzo)
- `Option`
- add `getOrElseW` (@gcanti)
- `Reader`
- add `chainW` (@gcanti)
- `ReaderEither`
- add `getOrElseW` (@gcanti)
- add `chainW` (@gcanti)
- add `chainEitherKW` (@giogonzo)
- `ReaderTaskEither`
- add `getOrElseW` (@gcanti)
- add `chainW` (@gcanti)
- add `chainEitherKW` (@giogonzo)
- add `chainTaskEitherKW` (@giogonzo)
- add `chainIOEitherKW` (@giogonzo)
- `StateReaderTaskEither`
- add `chainW` (@gcanti)
- add `chainEitherKW` (@giogonzo)
- add `chainTaskEitherKW` (@giogonzo)
- add `chainReaderTaskEitherKW` (@giogonzo)
- add `chainIOEitherKW` (@giogonzo)
- `TaskEither`
- add `getOrElseW` (@gcanti)
- add `chainW` (@gcanti)
- add `chainEitherKW` (@giogonzo)
- add `chainIOEitherKW` (@giogonzo)
- `Tree`
- add `fold` function (@gcanti)

Expand Down
23 changes: 22 additions & 1 deletion docs/guides/code-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ in `sequenceT` means *T*uple, I borrowed the name from the corresponding [Haskel

However usually it means *T*ransformer like in "monad transformers" (e.g. `OptionT`, `EitherT`, `ReaderT`, `StateT`)

### What a `K` suffix means, e.g. `fromEitherK` vs `chainEitherK`
### What a `K` suffix means, e.g. `fromEitherK` or `chainEitherK`

`K` means *K*leisli. A _Kleisli arrow_ is a function with the following signature

Expand Down Expand Up @@ -147,3 +147,24 @@ pipe(input, IE.chain(IE.fromEitherK(parse)))() // left(new Error('cannot decode
// or with less boilerplate
pipe(input, IE.chainEitherK(parse))() // left(new Error('cannot decode "foo" to number'))
```

### What a `W` suffix means, e.g. `chainW` or `chainEitherKW`

`W` means *W*iden. Functions that end with `W` are able to aggregate errors into a union (for `Either` based data types) or environments into an intersection (for `Reader` based data types).

**Example**

```ts
import * as E from 'fp-ts/lib/Either'
import * as TE from 'fp-ts/lib/TaskEither'
import { pipe } from 'fp-ts/lib/pipeable'

declare function parseString(s: string): E.Either<string, number>
declare function fetchUser(id: number): TE.TaskEither<Error, User>

// this raises an error because: Type 'string' is not assignable to type 'Error'
const program_ = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chain(fetchUser))

// const program: (s: string) => TE.TaskEither<string | Error, User>
const program = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chainW(fetchUser))
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fp-ts",
"version": "2.6.0",
"version": "2.6.1",
"description": "Functional programming in TypeScript",
"files": [
"lib",
Expand Down

0 comments on commit 977bcd2

Please sign in to comment.