From 977bcd23f6a174d872e2faa42e266a78cca5e4e7 Mon Sep 17 00:00:00 2001 From: gcanti Date: Thu, 14 May 2020 18:17:21 +0200 Subject: [PATCH] version 2.6.1 --- CHANGELOG.md | 13 ++++++++++++- docs/guides/code-conventions.md | 23 ++++++++++++++++++++++- package.json | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ccc54478..d3f3ebbba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) @@ -30,6 +30,7 @@ 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` @@ -37,14 +38,24 @@ high state of flux, you're at risk of it changing without notice. - `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) diff --git a/docs/guides/code-conventions.md b/docs/guides/code-conventions.md index 1d8362554..821521c69 100644 --- a/docs/guides/code-conventions.md +++ b/docs/guides/code-conventions.md @@ -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 @@ -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 +declare function fetchUser(id: number): TE.TaskEither + +// 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 +const program = (s: string) => pipe(s, TE.fromEitherK(parseString), TE.chainW(fetchUser)) +``` diff --git a/package.json b/package.json index 466355315..ae04f4700 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fp-ts", - "version": "2.6.0", + "version": "2.6.1", "description": "Functional programming in TypeScript", "files": [ "lib",