UNPKG

fp-ts

Version:

Functional programming in TypeScript

1,043 lines (1,042 loc) 30.9 kB
/** * `IOEither<E, A>` represents a synchronous computation that either yields a value of type `A` or fails yielding an * error of type `E`. * * If you want to represent a synchronous computation that never fails, please see `IO`. * If you want to represent a synchronous computation that may yield nothing, please see `IOOption`. * * @since 2.0.0 */ import { Alt2, Alt2C } from './Alt' import { Applicative2, Applicative2C } from './Applicative' import { Apply2 } from './Apply' import { Bifunctor2 } from './Bifunctor' import * as chainable from './Chain' import { Compactable2C } from './Compactable' import * as E from './Either' import { Filterable2C } from './Filterable' import { FromEither2 } from './FromEither' import { FromIO2 } from './FromIO' import { LazyArg } from './function' import { Functor2 } from './Functor' import * as I from './IO' import { Monad2, Monad2C } from './Monad' import { MonadIO2, MonadIO2C } from './MonadIO' import { MonadThrow2, MonadThrow2C } from './MonadThrow' import { Monoid } from './Monoid' import { Option } from './Option' import { Pointed2 } from './Pointed' import { Predicate } from './Predicate' import { ReadonlyNonEmptyArray } from './ReadonlyNonEmptyArray' import { Refinement } from './Refinement' import { Semigroup } from './Semigroup' import Either = E.Either import IO = I.IO /** * @category model * @since 2.0.0 */ export interface IOEither<E, A> extends IO<Either<E, A>> {} /** * @category constructors * @since 2.0.0 */ export declare const left: <E = never, A = never>(l: E) => IOEither<E, A> /** * @category constructors * @since 2.0.0 */ export declare const right: <E = never, A = never>(a: A) => IOEither<E, A> /** * @category constructors * @since 2.0.0 */ export declare const rightIO: <E = never, A = never>(ma: IO<A>) => IOEither<E, A> /** * @category constructors * @since 2.0.0 */ export declare const leftIO: <E = never, A = never>(me: IO<E>) => IOEither<E, A> /** * @category conversions * @since 2.0.0 */ export declare const fromEither: <E, A>(fa: Either<E, A>) => IOEither<E, A> /** * @category conversions * @since 2.7.0 */ export declare const fromIO: <A, E = never>(fa: IO<A>) => IOEither<E, A> /** * @category pattern matching * @since 2.10.0 */ export declare const match: <E, B, A>(onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: IOEither<E, A>) => IO<B> /** * Less strict version of [`match`](#match). * * The `W` suffix (short for **W**idening) means that the handler return types will be merged. * * @category pattern matching * @since 2.10.0 */ export declare const matchW: <E, B, A, C>( onLeft: (e: E) => B, onRight: (a: A) => C ) => (ma: IOEither<E, A>) => IO<B | C> /** * The `E` suffix (short for **E**ffect) means that the handlers return an effect (`IO`). * * @category pattern matching * @since 2.10.0 */ export declare const matchE: <E, A, B>( onLeft: (e: E) => IO<B>, onRight: (a: A) => IO<B> ) => (ma: IOEither<E, A>) => IO<B> /** * Alias of [`matchE`](#matche). * * @category pattern matching * @since 2.0.0 */ export declare const fold: <E, A, B>(onLeft: (e: E) => IO<B>, onRight: (a: A) => IO<B>) => (ma: IOEither<E, A>) => IO<B> /** * Less strict version of [`matchE`](#matche). * * The `W` suffix (short for **W**idening) means that the handler return types will be merged. * * @category pattern matching * @since 2.10.0 */ export declare const matchEW: <E, B, A, C>( onLeft: (e: E) => IO<B>, onRight: (a: A) => IO<C> ) => (ma: IOEither<E, A>) => IO<B | C> /** * Alias of [`matchEW`](#matchew). * * @category pattern matching * @since 2.10.0 */ export declare const foldW: <E, B, A, C>( onLeft: (e: E) => IO<B>, onRight: (a: A) => IO<C> ) => (ma: IOEither<E, A>) => IO<B | C> /** * @category error handling * @since 2.0.0 */ export declare const getOrElse: <E, A>(onLeft: (e: E) => IO<A>) => (ma: IOEither<E, A>) => IO<A> /** * Less strict version of [`getOrElse`](#getorelse). * * The `W` suffix (short for **W**idening) means that the handler return type will be merged. * * @category error handling * @since 2.6.0 */ export declare const getOrElseW: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: IOEither<E, A>) => IO<A | B> /** * Constructs a new `IOEither` from a function that performs a side effect and might throw * * See also [`tryCatchK`](#trycatchk). * * @category interop * @since 2.0.0 */ export declare const tryCatch: <E, A>(f: LazyArg<A>, onThrow: (reason: unknown) => E) => IOEither<E, A> /** * Converts a function that may throw to one returning a `IOEither`. * * @category interop * @since 2.10.0 */ export declare const tryCatchK: <A extends ReadonlyArray<unknown>, B, E>( f: (...a: A) => B, onThrow: (reason: unknown) => E ) => (...a: A) => IOEither<E, B> /** * @category conversions * @since 2.10.0 */ export declare const toUnion: <E, A>(fa: IOEither<E, A>) => IO<E | A> /** * @category error handling * @since 2.0.0 */ export declare const orElse: <E1, A, E2>(onLeft: (e: E1) => IOEither<E2, A>) => (ma: IOEither<E1, A>) => IOEither<E2, A> /** * Less strict version of [`orElse`](#orelse). * * The `W` suffix (short for **W**idening) means that the return types will be merged. * * @category error handling * @since 2.10.0 */ export declare const orElseW: <E1, E2, B>( onLeft: (e: E1) => IOEither<E2, B> ) => <A>(ma: IOEither<E1, A>) => IOEither<E2, A | B> /** * Returns an effect that effectfully "peeks" at the failure of this effect. * * @category error handling * @since 2.15.0 */ export declare const tapError: { <E1, E2, _>(onLeft: (e: E1) => IOEither<E2, _>): <A>(self: IOEither<E1, A>) => IOEither<E1 | E2, A> <E1, A, E2, _>(self: IOEither<E1, A>, onLeft: (e: E1) => IOEither<E2, _>): IOEither<E1 | E2, A> } /** * @category error handling * @since 2.12.0 */ export declare const orElseFirstIOK: <E, B>(onLeft: (e: E) => IO<B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A> /** * @category error handling * @since 2.11.0 */ export declare const orLeft: <E1, E2>(onLeft: (e: E1) => IO<E2>) => <A>(fa: IOEither<E1, A>) => IOEither<E2, A> /** * @since 2.0.0 */ export declare const swap: <E, A>(ma: IOEither<E, A>) => IOEither<A, E> /** * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types * use the type constructor `F` to represent some computational context. * * @category mapping * @since 2.0.0 */ export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: IOEither<E, A>) => IOEither<E, B> /** * Returns a `IOEither` whose failure and success channels have been mapped by the specified pair of functions, `f` and `g`. * * @example * import * as IOEither from 'fp-ts/IOEither' * import * as Either from 'fp-ts/Either' * * const f = (s: string) => new Error(s) * const g = (n: number) => n * 2 * * assert.deepStrictEqual(IOEither.mapBoth(IOEither.right(1), f, g)(), Either.right(2)) * assert.deepStrictEqual(IOEither.mapBoth(IOEither.left('err'), f, g)(), Either.left(new Error('err'))) * * @category error handling * @since 2.16.0 */ export declare const mapBoth: { <E, G, A, B>(f: (e: E) => G, g: (a: A) => B): (self: IOEither<E, A>) => IOEither<G, B> <E, A, G, B>(self: IOEither<E, A>, f: (e: E) => G, g: (a: A) => B): IOEither<G, B> } /** * Alias of `mapBoth`. * * @category legacy * @since 2.0.0 */ export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: IOEither<E, A>) => IOEither<G, B> /** * 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 declare const mapError: { <E, G>(f: (e: E) => G): <A>(self: IOEither<E, A>) => IOEither<G, A> <E, A, G>(self: IOEither<E, A>, f: (e: E) => G): IOEither<G, A> } /** * Alias of `mapError`. * * @category legacy * @since 2.0.0 */ export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: IOEither<E, A>) => IOEither<G, A> /** * @since 2.0.0 */ export declare const ap: <E, A>(fa: IOEither<E, A>) => <B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B> /** * Less strict version of [`ap`](#ap). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @since 2.8.0 */ export declare const apW: <E2, A>( fa: IOEither<E2, A> ) => <E1, B>(fab: IOEither<E1, (a: A) => B>) => IOEither<E1 | E2, B> /** * @category constructors * @since 2.8.5 */ export declare const of: <E = never, A = never>(a: A) => IOEither<E, A> /** * @category sequencing * @since 2.14.0 */ export declare const flatMap: { <A, E2, B>(f: (a: A) => IOEither<E2, B>): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> <E1, A, E2, B>(ma: IOEither<E1, A>, f: (a: A) => IOEither<E2, B>): IOEither<E1 | E2, B> } /** * Less strict version of [`flatten`](#flatten). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category sequencing * @since 2.11.0 */ export declare const flattenW: <E1, E2, A>(mma: IOEither<E1, IOEither<E2, A>>) => IOEither<E1 | E2, A> /** * @category sequencing * @since 2.0.0 */ export declare const flatten: <E, A>(mma: IOEither<E, IOEither<E, A>>) => IOEither<E, A> /** * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to * types of kind `* -> *`. * * @category error handling * @since 2.0.0 */ export declare const alt: <E, A>(that: LazyArg<IOEither<E, A>>) => (fa: IOEither<E, A>) => IOEither<E, A> /** * Less strict version of [`alt`](#alt). * * The `W` suffix (short for **W**idening) means that the error and the return types will be merged. * * @category error handling * @since 2.9.0 */ export declare const altW: <E2, B>( that: LazyArg<IOEither<E2, B>> ) => <E1, A>(fa: IOEither<E1, A>) => IOEither<E2, A | B> /** * @since 2.7.0 */ export declare const throwError: MonadThrow2<URI>['throwError'] /** * @category type lambdas * @since 2.0.0 */ export declare const URI = 'IOEither' /** * @category type lambdas * @since 2.0.0 */ export type URI = typeof URI declare module './HKT' { interface URItoKind2<E, A> { readonly [URI]: IOEither<E, A> } } /** * The default [`ApplicativePar`](#applicativepar) instance returns the first error, if you want to * get all errors you need to provide a way to concatenate them via a `Semigroup`. * * See [`getApplicativeValidation`](./Either.ts.html#getapplicativevalidation). * * @category error handling * @since 2.7.0 */ export declare function getApplicativeIOValidation<E>(S: Semigroup<E>): Applicative2C<URI, E> /** * The default [`Alt`](#alt) instance returns the last error, if you want to * get all errors you need to provide a way to concatenate them via a `Semigroup`. * * See [`getAltValidation`](./Either.ts.html#getaltvalidation). * * @category error handling * @since 2.7.0 */ export declare function getAltIOValidation<E>(S: Semigroup<E>): Alt2C<URI, E> /** * @category filtering * @since 2.10.0 */ export declare const getCompactable: <E>(M: Monoid<E>) => Compactable2C<URI, E> /** * @category filtering * @since 2.1.0 */ export declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E> /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor2<URI> /** * Maps the `Right` value of this `IOEither` to the specified constant value. * * @category mapping * @since 2.16.0 */ export declare const as: { <A>(a: A): <E, _>(self: IOEither<E, _>) => IOEither<E, A> <E, _, A>(self: IOEither<E, _>, a: A): IOEither<E, A> } /** * Maps the `Right` value of this `IOEither` to the void constant value. * * @category mapping * @since 2.16.0 */ export declare const asUnit: <E, _>(self: IOEither<E, _>) => IOEither<E, void> /** * @category mapping * @since 2.10.0 */ export declare const flap: <A>( a: A ) => <E, B>(fab: import('./HKT').Kind2<'IOEither', E, (a: A) => B>) => import('./HKT').Kind2<'IOEither', E, B> /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed2<URI> /** * @category instances * @since 2.7.0 */ export declare const Bifunctor: Bifunctor2<URI> /** * Runs computations in parallel. * * @category instances * @since 2.10.0 */ export declare const ApplyPar: Apply2<URI> /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.0.0 */ export declare const apFirst: <E, B>( second: IOEither<E, B> ) => <A>(first: import('./HKT').Kind2<'IOEither', E, A>) => import('./HKT').Kind2<'IOEither', E, A> /** * Less strict version of [`apFirst`](#apfirst). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @since 2.12.0 */ export declare const apFirstW: <E2, B>( second: IOEither<E2, B> ) => <E1, A>(first: IOEither<E1, A>) => IOEither<E1 | E2, A> /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: <E, B>( second: IOEither<E, B> ) => <A>(first: import('./HKT').Kind2<'IOEither', E, A>) => import('./HKT').Kind2<'IOEither', E, B> /** * Less strict version of [`apSecond`](#apsecond). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @since 2.12.0 */ export declare const apSecondW: <E2, B>( second: IOEither<E2, B> ) => <E1, A>(first: IOEither<E1, A>) => IOEither<E1 | E2, B> /** * Runs computations in parallel. * * @category instances * @since 2.8.4 */ export declare const ApplicativePar: Applicative2<URI> /** * Runs computations sequentially. * * @category instances * @since 2.8.4 */ export declare const ApplicativeSeq: Applicative2<URI> /** * @category instances * @since 2.10.0 */ export declare const Chain: chainable.Chain2<URI> /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad2<URI> /** * @category instances * @since 2.10.0 */ export declare const FromEither: FromEither2<URI> /** * @category instances * @since 2.10.0 */ export declare const FromIO: FromIO2<URI> /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @category combinators * @since 2.15.0 */ export declare const tap: { <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => IOEither<E2, _>): IOEither<E1 | E2, A> <A, E2, _>(f: (a: A) => IOEither<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A> } /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @example * import { pipe } from 'fp-ts/function' * import * as IOE from 'fp-ts/IOEither' * import * as E from 'fp-ts/Either' * * const compute = (value: string) => pipe( * IOE.of(value), * IOE.tapEither(() => value.length > 0 ? E.right('ok') : E.left('error')), * ) * * assert.deepStrictEqual(compute('')(), E.left('error')) * assert.deepStrictEqual(compute('fp-ts')(), E.right('fp-ts')) * * @category combinators * @since 2.16.0 */ export declare const tapEither: { <A, E2, _>(f: (a: A) => Either<E2, _>): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, A> <E1, A, E2, _>(self: IOEither<E1, A>, f: (a: A) => Either<E2, _>): IOEither<E1 | E2, A> } /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * @example * import { pipe } from 'fp-ts/function' * import * as IOE from 'fp-ts/IOEither' * import * as E from 'fp-ts/Either' * import * as Console from 'fp-ts/Console' * * const sayHello = (value: string) => Console.log(`Hello, ${value}`) * * // Will produce `Hello, fp-ts` to the stdout * const effectA = IOE.tapIO(IOE.of('fp-ts'), sayHello) * * // No output to the stdout * const effectB = pipe(IOE.left<string>('error'), IOE.tapIO(sayHello)) * * assert.deepStrictEqual(effectA(), E.right('fp-ts')) * assert.deepStrictEqual(effectB(), E.left('error')) * * @category combinators * @since 2.16.0 */ export declare const tapIO: { <A, _>(f: (a: A) => IO<_>): <E>(self: IOEither<E, A>) => IOEither<E, A> <E, A, _>(self: IOEither<E, A>, f: (a: A) => IO<_>): IOEither<E, A> } /** * @category instances * @since 2.7.0 */ export declare const Alt: Alt2<URI> /** * @category instances * @since 2.7.0 */ export declare const MonadIO: MonadIO2<URI> /** * @category instances * @since 2.7.0 */ export declare const MonadThrow: MonadThrow2<URI> /** * @category lifting * @since 2.10.0 */ export declare const fromIOK: <A extends ReadonlyArray<unknown>, B>( f: (...a: A) => I.IO<B> ) => <E = never>(...a: A) => IOEither<E, B> /** * Alias of `tapIO`. * * @category legacy * @since 2.10.0 */ export declare const chainFirstIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, A> /** * @category conversions * @since 2.0.0 */ export declare const fromOption: <E>(onNone: LazyArg<E>) => <A>(fa: Option<A>) => IOEither<E, A> /** * Use `liftOption`. * * @category legacy * @since 2.10.0 */ export declare const fromOptionK: <E>( onNone: LazyArg<E> ) => <A extends ReadonlyArray<unknown>, B>(f: (...a: A) => Option<B>) => (...a: A) => IOEither<E, B> /** * Use `flatMapOption`. * * @category legacy * @since 2.10.0 */ export declare const chainOptionK: <E>( onNone: LazyArg<E> ) => <A, B>(f: (a: A) => Option<B>) => (ma: IOEither<E, A>) => IOEither<E, B> /** * Use `flatMapOption`. * * @category legacy * @since 2.13.2 */ export declare const chainOptionKW: <E2>( onNone: LazyArg<E2> ) => <A, B>(f: (a: A) => Option<B>) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> /** * @category lifting * @since 2.15.0 */ export declare const liftNullable: <A extends ReadonlyArray<unknown>, B, E>( f: (...a: A) => B | null | undefined, onNullable: (...a: A) => E ) => (...a: A) => IOEither<E, NonNullable<B>> /** * @category lifting * @since 2.15.0 */ export declare const liftOption: <A extends ReadonlyArray<unknown>, B, E>( f: (...a: A) => Option<B>, onNone: (...a: A) => E ) => (...a: A) => IOEither<E, B> /** * @category sequencing * @since 2.15.0 */ export declare const flatMapNullable: { <A, B, E2>(f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): <E1>( self: IOEither<E1, A> ) => IOEither<E2 | E1, NonNullable<B>> <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => B | null | undefined, onNullable: (a: A) => E2): IOEither< E1 | E2, NonNullable<B> > } /** * @category sequencing * @since 2.15.0 */ export declare const flatMapOption: { <A, B, E2>(f: (a: A) => Option<B>, onNone: (a: A) => E2): <E1>(self: IOEither<E1, A>) => IOEither<E2 | E1, B> <E1, A, B, E2>(self: IOEither<E1, A>, f: (a: A) => Option<B>, onNone: (a: A) => E2): IOEither<E1 | E2, B> } /** * @category sequencing * @since 2.15.0 */ export declare const flatMapEither: { <A, E2, B>(f: (a: A) => E.Either<E2, B>): <E1>(self: IOEither<E1, A>) => IOEither<E1 | E2, B> <E1, A, E2, B>(self: IOEither<E1, A>, f: (a: A) => E.Either<E2, B>): IOEither<E1 | E2, B> } /** * @category sequencing * @since 2.16.0 */ export declare const flatMapIO: { <A, B>(f: (a: A) => IO<B>): <E>(self: IOEither<E, A>) => IOEither<E, B> <E, A, B>(self: IOEither<E, A>, f: (a: A) => IO<B>): IOEither<E, B> } /** * Alias of `flatMapIO`. * @category legacy * @since 2.10.0 */ export declare const chainIOK: <A, B>(f: (a: A) => I.IO<B>) => <E>(first: IOEither<E, A>) => IOEither<E, B> /** * Alias of `flatMapEither`. * * @category legacy * @since 2.4.0 */ export declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B> /** * Alias of `flatMapEither`. * * @category legacy * @since 2.6.1 */ export declare const chainEitherKW: <E2, A, B>( f: (a: A) => Either<E2, B> ) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> /** * Alias of `tapEither`. * * @category legacy * @since 2.12.0 */ export declare const chainFirstEitherK: <A, E, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A> /** * Alias of `tapEither`. * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category legacy * @since 2.12.0 */ export declare const chainFirstEitherKW: <A, E2, B>( f: (a: A) => E.Either<E2, B> ) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> /** * @category lifting * @since 2.0.0 */ export declare const fromPredicate: { <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (a: A) => IOEither<E, B> <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(b: B) => IOEither<E, B> <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (a: A) => IOEither<E, A> } /** * @category filtering * @since 2.0.0 */ export declare const filterOrElse: { <E, A, B extends A>(refinement: Refinement<A, B>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, B> <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): <B extends A>(mb: IOEither<E, B>) => IOEither<E, B> <E, A>(predicate: Predicate<A>, onFalse: (a: A) => E): (ma: IOEither<E, A>) => IOEither<E, A> } /** * Less strict version of [`filterOrElse`](#filterorelse). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category filtering * @since 2.9.0 */ export declare const filterOrElseW: { <A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>( ma: IOEither<E1, A> ) => IOEither<E1 | E2, B> <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1, B extends A>( mb: IOEither<E1, B> ) => IOEither<E1 | E2, B> <A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> } /** * @category lifting * @since 2.4.0 */ export declare const fromEitherK: <E, A extends ReadonlyArray<unknown>, B>( f: (...a: A) => E.Either<E, B> ) => (...a: A) => IOEither<E, B> /** * Make sure that a resource is cleaned up in the event of an exception (\*). The release action is called regardless of * whether the body action throws (\*) or returns. * * (\*) i.e. returns a `Left` * * @since 2.0.0 */ export declare const bracket: <E, A, B>( acquire: IOEither<E, A>, use: (a: A) => IOEither<E, B>, release: (a: A, e: Either<E, B>) => IOEither<E, void> ) => IOEither<E, B> /** * Less strict version of [`bracket`](#bracket). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @since 2.12.0 */ export declare const bracketW: <E1, A, E2, B, E3>( acquire: IOEither<E1, A>, use: (a: A) => IOEither<E2, B>, release: (a: A, e: E.Either<E2, B>) => IOEither<E3, void> ) => IOEither<E1 | E2 | E3, B> /** * @category do notation * @since 2.9.0 */ export declare const Do: IOEither<never, {}> /** * @category do notation * @since 2.8.0 */ export declare const bindTo: <N extends string>( name: N ) => <E, A>( fa: import('./HKT').Kind2<'IOEither', E, A> ) => import('./HKT').Kind2<'IOEither', E, { readonly [K in N]: A }> declare const let_: <N extends string, A, B>( name: Exclude<N, keyof A>, f: (a: A) => B ) => <E>( fa: import('./HKT').Kind2<'IOEither', E, A> ) => import('./HKT').Kind2<'IOEither', E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> export { /** * @category do notation * @since 2.13.0 */ let_ as let } /** * @category do notation * @since 2.8.0 */ export declare const bind: <N extends string, A, E, B>( name: Exclude<N, keyof A>, f: (a: A) => import('./HKT').Kind2<'IOEither', E, B> ) => ( ma: import('./HKT').Kind2<'IOEither', E, A> ) => import('./HKT').Kind2<'IOEither', E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> /** * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category do notation * @since 2.8.0 */ export declare const bindW: <N extends string, A, E2, B>( name: Exclude<N, keyof A>, f: (a: A) => IOEither<E2, B> ) => <E1>(fa: IOEither<E1, A>) => IOEither< E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B } > /** * @category do notation * @since 2.8.0 */ export declare const apS: <N extends string, A, E, B>( name: Exclude<N, keyof A>, fb: IOEither<E, B> ) => ( fa: import('./HKT').Kind2<'IOEither', E, A> ) => import('./HKT').Kind2<'IOEither', E, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B }> /** * Less strict version of [`apS`](#aps). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category do notation * @since 2.8.0 */ export declare const apSW: <A, N extends string, E2, B>( name: Exclude<N, keyof A>, fb: IOEither<E2, B> ) => <E1>(fa: IOEither<E1, A>) => IOEither< E1 | E2, { readonly [K in keyof A | N]: K extends keyof A ? A[K] : B } > /** * @since 2.11.0 */ export declare const ApT: IOEither<never, readonly []> /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: <A, E, B>( f: (index: number, a: A) => IOEither<E, B> ) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: <A, E, B>( f: (index: number, a: A) => IOEither<E, B> ) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: <A, E, B>( f: (index: number, a: A) => IOEither<E, B> ) => (as: ReadonlyNonEmptyArray<A>) => IOEither<E, ReadonlyNonEmptyArray<B>> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndexSeq: <A, E, B>( f: (index: number, a: A) => IOEither<E, B> ) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArrayWithIndex: <A, E, B>( f: (index: number, a: A) => IOEither<E, B> ) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArray: <A, E, B>( f: (a: A) => IOEither<E, B> ) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: <E, A>(arr: ReadonlyArray<IOEither<E, A>>) => IOEither<E, ReadonlyArray<A>> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.9.0 */ export declare const traverseSeqArrayWithIndex: <A, E, B>( f: (index: number, a: A) => IOEither<E, B> ) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> /** * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`. * * @category traversing * @since 2.9.0 */ export declare const traverseSeqArray: <A, E, B>( f: (a: A) => IOEither<E, B> ) => (as: ReadonlyArray<A>) => IOEither<E, ReadonlyArray<B>> /** * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceSeqArray: <E, A>(arr: ReadonlyArray<IOEither<E, A>>) => IOEither<E, ReadonlyArray<A>> /** * Use [`ApplicativePar`](#applicativepar) instead * * @category zone of death * @since 2.7.0 * @deprecated */ export declare const Applicative: Applicative2<URI> /** * Alias of `flatMap`. * * @category legacy * @since 2.0.0 */ export declare const chain: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B> /** * Alias of `flatMap`. * * @category legacy * @since 2.6.0 */ export declare const chainW: <E2, A, B>( f: (a: A) => IOEither<E2, B> ) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, B> /** * Alias of `tap`. * * @category legacy * @since 2.0.0 */ export declare const chainFirst: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A> /** * Alias of `tap`. * * @category legacy * @since 2.8.0 */ export declare const chainFirstW: <E2, A, B>( f: (a: A) => IOEither<E2, B> ) => <E1>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> /** * Alias of `tapError`. * * @category legacy * @since 2.11.0 */ export declare const orElseFirst: <E, B>(onLeft: (e: E) => IOEither<E, B>) => <A>(ma: IOEither<E, A>) => IOEither<E, A> /** * Alias of `tapError`. * * @category legacy * @since 2.11.0 */ export declare const orElseFirstW: <E1, E2, B>( onLeft: (e: E1) => IOEither<E2, B> ) => <A>(ma: IOEither<E1, A>) => IOEither<E1 | E2, A> /** * This instance is deprecated, use small, specific instances instead. * For example if a function needs a `Functor` instance, pass `IOE.Functor` instead of `IOE.ioEither` * (where `IOE` is from `import IOE from 'fp-ts/IOEither'`) * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const ioEither: Monad2<URI> & Bifunctor2<URI> & Alt2<URI> & MonadIO2<URI> & MonadThrow2<URI> /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplySemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>> /** * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplyMonoid: <E, A>(M: Monoid<A>) => Monoid<IOEither<E, A>> /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getSemigroup: <E, A>(S: Semigroup<A>) => Semigroup<IOEither<E, A>> /** * Use [`getApplicativeIOValidation`](#getapplicativeiovalidation) and [`getAltIOValidation`](#getaltiovalidation). * * @category zone of death * @since 2.0.0 * @deprecated */ export declare function getIOValidation<E>( SE: Semigroup<E> ): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadIO2C<URI, E> & MonadThrow2C<URI, E>