From 7929c1781f0999b2af99f27caf40c588983dc086 Mon Sep 17 00:00:00 2001 From: gcanti Date: Fri, 19 May 2023 19:18:02 +0200 Subject: [PATCH] add mapError --- docs/modules/EitherT.ts.md | 12 +++---- docs/modules/IOEither.ts.md | 38 +++++++++++++++++++--- docs/modules/ReaderEither.ts.md | 38 +++++++++++++++++++--- docs/modules/ReaderTaskEither.ts.md | 49 ++++++++++++++++++++++++----- docs/modules/TaskEither.ts.md | 42 ++++++++++++++++++++++--- src/EitherT.ts | 36 ++++++++++++++++----- src/IOEither.ts | 34 ++++++++++++++------ src/ReaderEither.ts | 33 ++++++++++++++----- src/ReaderTaskEither.ts | 38 +++++++++++++++++----- src/TaskEither.ts | 39 +++++++++++++++++------ 10 files changed, 289 insertions(+), 70 deletions(-) diff --git a/docs/modules/EitherT.ts.md b/docs/modules/EitherT.ts.md index ff8fe4129..7b8da962f 100644 --- a/docs/modules/EitherT.ts.md +++ b/docs/modules/EitherT.ts.md @@ -559,22 +559,22 @@ Added in v2.10.0 ```ts export declare function mapLeft( F: Functor3 -): (f: (e: E) => G) => (fea: Kind3>) => Kind3> +): (f: (e: E) => G) => (self: Kind3>) => Kind3> export declare function mapLeft( F: Functor3C -): (f: (e: E) => G) => (fea: Kind3>) => Kind3> +): (f: (e: E) => G) => (self: Kind3>) => Kind3> export declare function mapLeft( F: Functor2 -): (f: (e: E) => G) => (fea: Kind2>) => Kind2> +): (f: (e: E) => G) => (self: Kind2>) => Kind2> export declare function mapLeft( F: Functor2C -): (f: (e: E) => G) => (fea: Kind2>) => Kind2> +): (f: (e: E) => G) => (self: Kind2>) => Kind2> export declare function mapLeft( F: Functor1 -): (f: (e: E) => G) => (fea: Kind>) => Kind> +): (f: (e: E) => G) => (self: Kind>) => Kind> export declare function mapLeft( F: Functor -): (f: (e: E) => G) => (fea: HKT>) => HKT> +): (f: (e: E) => G) => (self: HKT>) => HKT> ``` Added in v2.10.0 diff --git a/docs/modules/IOEither.ts.md b/docs/modules/IOEither.ts.md index 698ae0bf1..4b71fcd6a 100644 --- a/docs/modules/IOEither.ts.md +++ b/docs/modules/IOEither.ts.md @@ -48,7 +48,7 @@ Added in v2.0.0 - [getApplicativeIOValidation](#getapplicativeiovalidation) - [getOrElse](#getorelse) - [getOrElseW](#getorelsew) - - [mapLeft](#mapleft) + - [mapError](#maperror) - [orElse](#orelse) - [orElseFirstIOK](#orelsefirstiok) - [orElseW](#orelsew) @@ -89,6 +89,7 @@ Added in v2.0.0 - [chainOptionKW](#chainoptionkw) - [chainW](#chainw) - [fromOptionK](#fromoptionk) + - [mapLeft](#mapleft) - [orElseFirst](#orelsefirst) - [orElseFirstW](#orelsefirstw) - [lifting](#lifting) @@ -515,17 +516,32 @@ export declare const getOrElseW: (onLeft: (e: E) => I.IO) => (ma: IO Added in v2.6.0 -## mapLeft +## mapError -Map a function over the first type argument of a bifunctor. +Returns a `IOEither` with its error channel mapped using the specified function. **Signature** ```ts -export declare const mapLeft: (f: (e: E) => G) => (fa: IOEither) => IOEither +export declare const mapError: { + (f: (e: E) => G): (self: IOEither) => IOEither + (self: IOEither, f: (e: E) => G): IOEither +} ``` -Added in v2.0.0 +**Example** + +```ts +import * as IOEither from 'fp-ts/IOEither' +import * as Either from 'fp-ts/Either' + +const f = (s: string) => new Error(s) + +assert.deepStrictEqual(IOEither.mapError(IOEither.right(1), f)(), Either.right(1)) +assert.deepStrictEqual(IOEither.mapError(IOEither.left('err'), f)(), Either.left(new Error('err'))) +``` + +Added in v2.16.0 ## orElse @@ -977,6 +993,18 @@ export declare const fromOptionK: ( Added in v2.10.0 +## mapLeft + +Alias of `mapError`. + +**Signature** + +```ts +export declare const mapLeft: (f: (e: E) => G) => (fa: IOEither) => IOEither +``` + +Added in v2.0.0 + ## orElseFirst Alias of `tapError`. diff --git a/docs/modules/ReaderEither.ts.md b/docs/modules/ReaderEither.ts.md index 1696338c2..a844ae20e 100644 --- a/docs/modules/ReaderEither.ts.md +++ b/docs/modules/ReaderEither.ts.md @@ -45,7 +45,7 @@ Added in v2.0.0 - [getApplicativeReaderValidation](#getapplicativereadervalidation) - [getOrElse](#getorelse) - [getOrElseW](#getorelsew) - - [mapLeft](#mapleft) + - [mapError](#maperror) - [orElse](#orelse) - [orElseW](#orelsew) - [orLeft](#orleft) @@ -79,6 +79,7 @@ Added in v2.0.0 - [chainOptionKW](#chainoptionkw) - [chainW](#chainw) - [fromOptionK](#fromoptionk) + - [mapLeft](#mapleft) - [orElseFirst](#orelsefirst) - [orElseFirstW](#orelsefirstw) - [lifting](#lifting) @@ -537,17 +538,32 @@ export declare const getOrElseW: ( Added in v2.6.0 -## mapLeft +## mapError -Map a function over the second type argument of a bifunctor. +Returns a `ReaderEither` with its error channel mapped using the specified function. **Signature** ```ts -export declare const mapLeft: (f: (e: E) => G) => (fa: ReaderEither) => ReaderEither +export declare const mapError: { + (f: (e: E) => G): (self: ReaderEither) => ReaderEither + (self: ReaderEither, f: (e: E) => G): ReaderEither +} ``` -Added in v2.0.0 +**Example** + +```ts +import * as ReaderEither from 'fp-ts/ReaderEither' +import * as Either from 'fp-ts/Either' + +const f = (s: string) => new Error(s) + +assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.right(1), f)({}), Either.right(1)) +assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.left('err'), f)({}), Either.left(new Error('err'))) +``` + +Added in v2.16.0 ## orElse @@ -946,6 +962,18 @@ export declare const fromOptionK: ( Added in v2.10.0 +## mapLeft + +Alias of `mapError`. + +**Signature** + +```ts +export declare const mapLeft: (f: (e: E) => G) => (fa: ReaderEither) => ReaderEither +``` + +Added in v2.0.0 + ## orElseFirst Alias of `tapError`. diff --git a/docs/modules/ReaderTaskEither.ts.md b/docs/modules/ReaderTaskEither.ts.md index b61d34498..65000d58d 100644 --- a/docs/modules/ReaderTaskEither.ts.md +++ b/docs/modules/ReaderTaskEither.ts.md @@ -61,7 +61,7 @@ Added in v2.0.0 - [getApplicativeReaderTaskValidation](#getapplicativereadertaskvalidation) - [getOrElse](#getorelse) - [getOrElseW](#getorelsew) - - [mapLeft](#mapleft) + - [mapError](#maperror) - [orElse](#orelse) - [orElseW](#orelsew) - [orLeft](#orleft) @@ -106,6 +106,7 @@ Added in v2.0.0 - [chainW](#chainw) - [fromNullableK](#fromnullablek) - [fromOptionK](#fromoptionk) + - [mapLeft](#mapleft) - [orElseFirst](#orelsefirst) - [orElseFirstW](#orelsefirstw) - [lifting](#lifting) @@ -816,19 +817,39 @@ export declare const getOrElseW: ( Added in v2.6.0 -## mapLeft +## mapError -Map a function over the second type argument of a bifunctor. +Returns a `ReaderTaskEither` with its error channel mapped using the specified function. **Signature** ```ts -export declare const mapLeft: ( - f: (e: E) => G -) => (fa: ReaderTaskEither) => ReaderTaskEither +export declare const mapError: { + (f: (e: E) => G): (self: ReaderTaskEither) => ReaderTaskEither + (self: ReaderTaskEither, f: (e: E) => G): ReaderTaskEither +} ``` -Added in v2.0.0 +**Example** + +```ts +import * as ReaderTaskEither from 'fp-ts/ReaderTaskEither' +import * as Either from 'fp-ts/Either' + +const f = (s: string) => new Error(s) + +async function test() { + assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.right(1), f)({})(), Either.right(1)) + assert.deepStrictEqual( + await ReaderTaskEither.mapError(ReaderTaskEither.left('err'), f)({})(), + Either.left(new Error('err')) + ) +} + +test() +``` + +Added in v2.16.0 ## orElse @@ -1368,6 +1389,20 @@ export declare const fromOptionK: ( Added in v2.10.0 +## mapLeft + +Alias of `mapError`. + +**Signature** + +```ts +export declare const mapLeft: ( + f: (e: E) => G +) => (fa: ReaderTaskEither) => ReaderTaskEither +``` + +Added in v2.0.0 + ## orElseFirst Alias of `tapError`. diff --git a/docs/modules/TaskEither.ts.md b/docs/modules/TaskEither.ts.md index d5cd983f9..6fbe77c46 100644 --- a/docs/modules/TaskEither.ts.md +++ b/docs/modules/TaskEither.ts.md @@ -56,7 +56,7 @@ Added in v2.0.0 - [getApplicativeTaskValidation](#getapplicativetaskvalidation) - [getOrElse](#getorelse) - [getOrElseW](#getorelsew) - - [mapLeft](#mapleft) + - [mapError](#maperror) - [orElse](#orelse) - [orElseFirstIOK](#orelsefirstiok) - [orElseFirstTaskK](#orelsefirsttaskk) @@ -105,6 +105,7 @@ Added in v2.0.0 - [chainW](#chainw) - [fromNullableK](#fromnullablek) - [fromOptionK](#fromoptionk) + - [mapLeft](#mapleft) - [orElseFirst](#orelsefirst) - [orElseFirstW](#orelsefirstw) - [lifting](#lifting) @@ -722,17 +723,36 @@ export declare const getOrElseW: (onLeft: (e: E) => T.Task) => (ma: Added in v2.6.0 -## mapLeft +## mapError -Map a function over the first type argument of a bifunctor. +Returns a `TaskEither` with its error channel mapped using the specified function. **Signature** ```ts -export declare const mapLeft: (f: (e: E) => G) => (fa: TaskEither) => TaskEither +export declare const mapError: { + (f: (e: E) => G): (self: TaskEither) => TaskEither + (self: TaskEither, f: (e: E) => G): TaskEither +} ``` -Added in v2.0.0 +**Example** + +```ts +import * as TaskEither from 'fp-ts/TaskEither' +import * as Either from 'fp-ts/Either' + +const f = (s: string) => new Error(s) + +async function test() { + assert.deepStrictEqual(await TaskEither.mapError(TaskEither.right(1), f)(), Either.right(1)) + assert.deepStrictEqual(await TaskEither.mapError(TaskEither.left('err'), f)(), Either.left(new Error('err'))) +} + +test() +``` + +Added in v2.16.0 ## orElse @@ -1362,6 +1382,18 @@ export declare const fromOptionK: ( Added in v2.10.0 +## mapLeft + +Alias of `mapError`. + +**Signature** + +```ts +export declare const mapLeft: (f: (e: E) => G) => (fa: TaskEither) => TaskEither +``` + +Added in v2.0.0 + ## orElseFirst Alias of `tapError`. diff --git a/src/EitherT.ts b/src/EitherT.ts index 0cd2d32b9..9dc721057 100644 --- a/src/EitherT.ts +++ b/src/EitherT.ts @@ -412,26 +412,46 @@ export function bimap( */ export function mapLeft( F: Functor3 -): (f: (e: E) => G) => (fea: Kind3>) => Kind3> +): (f: (e: E) => G) => (self: Kind3>) => Kind3> export function mapLeft( F: Functor3C -): (f: (e: E) => G) => (fea: Kind3>) => Kind3> +): (f: (e: E) => G) => (self: Kind3>) => Kind3> export function mapLeft( F: Functor2 -): (f: (e: E) => G) => (fea: Kind2>) => Kind2> +): (f: (e: E) => G) => (self: Kind2>) => Kind2> export function mapLeft( F: Functor2C -): (f: (e: E) => G) => (fea: Kind2>) => Kind2> +): (f: (e: E) => G) => (self: Kind2>) => Kind2> export function mapLeft( F: Functor1 -): (f: (e: E) => G) => (fea: Kind>) => Kind> +): (f: (e: E) => G) => (self: Kind>) => Kind> export function mapLeft( F: Functor -): (f: (e: E) => G) => (fea: HKT>) => HKT> +): (f: (e: E) => G) => (self: HKT>) => HKT> export function mapLeft( F: Functor -): (f: (e: E) => G) => (fea: HKT>) => HKT> { - return (f) => (fea) => F.map(fea, E.mapLeft(f)) +): (f: (e: E) => G) => (self: HKT>) => HKT> { + const mapErrorF = mapError(F) + return (f) => (self) => mapErrorF(self, f) +} + +/** @internal */ +export function mapError( + F: Functor2 +): (self: Kind2>, f: (e: E) => G) => Kind2> +/** @internal */ +export function mapError( + F: Functor1 +): (self: Kind>, f: (e: E) => G) => Kind> +/** @internal */ +export function mapError( + F: Functor +): (self: HKT>, f: (e: E) => G) => HKT> +/** @internal */ +export function mapError( + F: Functor +): (self: HKT>, f: (e: E) => G) => HKT> { + return (self, f) => F.map(self, E.mapLeft(f)) } /** diff --git a/src/IOEither.ts b/src/IOEither.ts index 6b4b65f35..fbdf86e34 100644 --- a/src/IOEither.ts +++ b/src/IOEither.ts @@ -282,8 +282,6 @@ const _apSeq: Apply2['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map( /* istanbul ignore next */ const _bimap: Bifunctor2['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g)) /* istanbul ignore next */ -const _mapLeft: Bifunctor2['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f)) -/* istanbul ignore next */ const _alt: Alt2['alt'] = (fa, that) => pipe(fa, alt(that)) /** @@ -305,14 +303,32 @@ export const bimap: (f: (e: E) => G, g: (a: A) => B) => (fa: IOEithe /*#__PURE__*/ ET.bimap(I.Functor) /** - * Map a function over the first type argument of a bifunctor. + * Returns a `IOEither` with its error channel mapped using the specified function. + * + * @example + * import * as IOEither from 'fp-ts/IOEither' + * import * as Either from 'fp-ts/Either' + * + * const f = (s: string) => new Error(s) + * + * assert.deepStrictEqual(IOEither.mapError(IOEither.right(1), f)(), Either.right(1)) + * assert.deepStrictEqual(IOEither.mapError(IOEither.left('err'), f)(), Either.left(new Error('err'))) * * @category error handling + * @since 2.16.0 + */ +export const mapError: { + (f: (e: E) => G): (self: IOEither) => IOEither + (self: IOEither, f: (e: E) => G): IOEither +} = /*#__PURE__*/ dual(2, ET.mapError(I.Functor)) + +/** + * Alias of `mapError`. + * + * @category legacy * @since 2.0.0 */ -export const mapLeft: (f: (e: E) => G) => (fa: IOEither) => IOEither = /*#__PURE__*/ ET.mapLeft( - I.Functor -) +export const mapLeft: (f: (e: E) => G) => (fa: IOEither) => IOEither = mapError /** * @since 2.0.0 @@ -534,7 +550,7 @@ export const Pointed: Pointed2 = { export const Bifunctor: Bifunctor2 = { URI, bimap: _bimap, - mapLeft: _mapLeft + mapLeft: mapError } /** @@ -1280,7 +1296,7 @@ export const orElseFirstW: ( export const ioEither: Monad2 & Bifunctor2 & Alt2 & MonadIO2 & MonadThrow2 = { URI, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, map: _map, of, ap: _ap, @@ -1340,7 +1356,7 @@ export function getIOValidation( of, chain: flatMap, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, alt: altIOValidation.alt, fromIO, throwError diff --git a/src/ReaderEither.ts b/src/ReaderEither.ts index 7b9ac5e93..3aab6bad1 100644 --- a/src/ReaderEither.ts +++ b/src/ReaderEither.ts @@ -290,8 +290,6 @@ const _map: Monad3['map'] = (fa, f) => pipe(fa, map(f)) /* istanbul ignore next */ const _bimap: Bifunctor3['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g)) /* istanbul ignore next */ -const _mapLeft: Bifunctor3['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f)) -/* istanbul ignore next */ const _ap: Monad3['ap'] = (fab, fa) => pipe(fab, ap(fa)) /* istanbul ignore next */ const _alt: Alt3['alt'] = (fa, that) => pipe(fa, alt(that)) @@ -318,13 +316,32 @@ export const bimap: ( ) => (fa: ReaderEither) => ReaderEither = /*#__PURE__*/ ET.bimap(R.Functor) /** - * Map a function over the second type argument of a bifunctor. + * Returns a `ReaderEither` with its error channel mapped using the specified function. + * + * @example + * import * as ReaderEither from 'fp-ts/ReaderEither' + * import * as Either from 'fp-ts/Either' + * + * const f = (s: string) => new Error(s) + * + * assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.right(1), f)({}), Either.right(1)) + * assert.deepStrictEqual(ReaderEither.mapError(ReaderEither.left('err'), f)({}), Either.left(new Error('err'))) * * @category error handling + * @since 2.16.0 + */ +export const mapError: { + (f: (e: E) => G): (self: ReaderEither) => ReaderEither + (self: ReaderEither, f: (e: E) => G): ReaderEither +} = /*#__PURE__*/ dual(2, ET.mapError(R.Functor)) + +/** + * Alias of `mapError`. + * + * @category legacy * @since 2.0.0 */ -export const mapLeft: (f: (e: E) => G) => (fa: ReaderEither) => ReaderEither = - /*#__PURE__*/ ET.mapLeft(R.Functor) +export const mapLeft: (f: (e: E) => G) => (fa: ReaderEither) => ReaderEither = mapError /** * @since 2.0.0 @@ -692,7 +709,7 @@ export const tapEither: { export const Bifunctor: Bifunctor3 = { URI, bimap: _bimap, - mapLeft: _mapLeft + mapLeft: mapError } /** @@ -1209,7 +1226,7 @@ export const orElseFirstW: ( export const readerEither: Monad3 & Bifunctor3 & Alt3 & MonadThrow3 = { URI, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, map: _map, of, ap: _ap, @@ -1268,7 +1285,7 @@ export function getReaderValidation( of, chain: flatMap, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, alt: altReaderValidation.alt, throwError } diff --git a/src/ReaderTaskEither.ts b/src/ReaderTaskEither.ts index ef9513c01..c535af172 100644 --- a/src/ReaderTaskEither.ts +++ b/src/ReaderTaskEither.ts @@ -574,8 +574,6 @@ const _apSeq: Apply3['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map( const _alt: Alt3['alt'] = (fa, that) => pipe(fa, alt(that)) /* istanbul ignore next */ const _bimap: Bifunctor3['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g)) -/* istanbul ignore next */ -const _mapLeft: Bifunctor3['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f)) /** * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` whose argument and return types @@ -599,13 +597,37 @@ export const bimap: ( ) => (fa: ReaderTaskEither) => ReaderTaskEither = /*#__PURE__*/ ET.bimap(RT.Functor) /** - * Map a function over the second type argument of a bifunctor. + * Returns a `ReaderTaskEither` with its error channel mapped using the specified function. + * + * @example + * import * as ReaderTaskEither from 'fp-ts/ReaderTaskEither' + * import * as Either from 'fp-ts/Either' + * + * const f = (s: string) => new Error(s) + * + * async function test() { + * assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.right(1), f)({})(), Either.right(1)) + * assert.deepStrictEqual(await ReaderTaskEither.mapError(ReaderTaskEither.left('err'), f)({})(), Either.left(new Error('err'))) + * } + * + * test() * * @category error handling + * @since 2.16.0 + */ +export const mapError: { + (f: (e: E) => G): (self: ReaderTaskEither) => ReaderTaskEither + (self: ReaderTaskEither, f: (e: E) => G): ReaderTaskEither +} = /*#__PURE__*/ dual(2, ET.mapError(RT.Functor)) + +/** + * Alias of `mapError`. + * + * @category legacy * @since 2.0.0 */ export const mapLeft: (f: (e: E) => G) => (fa: ReaderTaskEither) => ReaderTaskEither = - /*#__PURE__*/ ET.mapLeft(RT.Functor) + mapError /** * @since 2.0.0 @@ -1124,7 +1146,7 @@ export const tapTask: { export const Bifunctor: Bifunctor3 = { URI, bimap: _bimap, - mapLeft: _mapLeft + mapLeft: mapError } /** @@ -1883,7 +1905,7 @@ export const readerTaskEither: Monad3 & Bifunctor3 & Alt3 & Monad chain: flatMap, alt: _alt, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, fromIO, fromTask, throwError @@ -1907,7 +1929,7 @@ export const readerTaskEitherSeq: typeof readerTaskEither = { chain: flatMap, alt: _alt, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, fromIO, fromTask, throwError @@ -1965,7 +1987,7 @@ export function getReaderTaskValidation( of, chain: flatMap, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, ap: applicativeReaderTaskValidation.ap, alt: altReaderTaskValidation.alt, fromIO, diff --git a/src/TaskEither.ts b/src/TaskEither.ts index 03bea17be..1f2430148 100644 --- a/src/TaskEither.ts +++ b/src/TaskEither.ts @@ -450,8 +450,6 @@ const _apSeq: Apply2['ap'] = (fab, fa) => flatMap(fab, (f) => pipe(fa, map( /* istanbul ignore next */ const _bimap: Bifunctor2['bimap'] = (fa, f, g) => pipe(fa, bimap(f, g)) /* istanbul ignore next */ -const _mapLeft: Bifunctor2['mapLeft'] = (fa, f) => pipe(fa, mapLeft(f)) -/* istanbul ignore next */ const _alt: Alt2['alt'] = (fa, that) => pipe(fa, alt(that)) /** @@ -475,13 +473,36 @@ export const bimap: (f: (e: E) => G, g: (a: A) => B) => (fa: TaskEit /*#__PURE__*/ ET.bimap(T.Functor) /** - * Map a function over the first type argument of a bifunctor. + * Returns a `TaskEither` with its error channel mapped using the specified function. + * + * @example + * import * as TaskEither from 'fp-ts/TaskEither' + * import * as Either from 'fp-ts/Either' + * + * const f = (s: string) => new Error(s) + * + * async function test() { + * assert.deepStrictEqual(await TaskEither.mapError(TaskEither.right(1), f)(), Either.right(1)) + * assert.deepStrictEqual(await TaskEither.mapError(TaskEither.left('err'), f)(), Either.left(new Error('err'))) + * } + * + * test() * * @category error handling + * @since 2.16.0 + */ +export const mapError: { + (f: (e: E) => G): (self: TaskEither) => TaskEither + (self: TaskEither, f: (e: E) => G): TaskEither +} = /*#__PURE__*/ dual(2, ET.mapError(T.Functor)) + +/** + * Alias of `mapError`. + * + * @category legacy * @since 2.0.0 */ -export const mapLeft: (f: (e: E) => G) => (fa: TaskEither) => TaskEither = - /*#__PURE__*/ ET.mapLeft(T.Functor) +export const mapLeft: (f: (e: E) => G) => (fa: TaskEither) => TaskEither = mapError /** * @since 2.0.0 @@ -1069,7 +1090,7 @@ export const tapTask: { export const Bifunctor: Bifunctor2 = { URI, bimap: _bimap, - mapLeft: _mapLeft + mapLeft: mapError } /** @@ -1680,7 +1701,7 @@ export const orElseFirstW: ( export const taskEither: Monad2 & Bifunctor2 & Alt2 & MonadTask2 & MonadThrow2 = { URI, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, map: _map, of, ap: _apPar, @@ -1704,7 +1725,7 @@ export const taskEither: Monad2 & Bifunctor2 & Alt2 & MonadTask2< export const taskEitherSeq: typeof taskEither = { URI, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, map: _map, of, ap: _apSeq, @@ -1765,7 +1786,7 @@ export function getTaskValidation( of, chain: flatMap, bimap: _bimap, - mapLeft: _mapLeft, + mapLeft: mapError, alt: altTaskValidation.alt, fromIO, fromTask,