/** * `IOEither` 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 { Chain2 } from './Chain' import { Compactable2C } from './Compactable' import * as E from './Either' import { Filterable2C } from './Filterable' import { FromEither2 } from './FromEither' import { FromIO2 } from './FromIO' import { Lazy } 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 extends IO> {} /** * @category constructors * @since 2.0.0 */ export declare const left: (l: E) => IOEither /** * @category constructors * @since 2.0.0 */ export declare const right: (a: A) => IOEither /** * @category constructors * @since 2.0.0 */ export declare const rightIO: (ma: IO) => IOEither /** * @category constructors * @since 2.0.0 */ export declare const leftIO: (me: IO) => IOEither /** * @category conversions * @since 2.0.0 */ export declare const fromEither: (fa: Either) => IOEither /** * @category conversions * @since 2.7.0 */ export declare const fromIO: (fa: IO) => IOEither /** * @category pattern matching * @since 2.10.0 */ export declare const match: (onLeft: (e: E) => B, onRight: (a: A) => B) => (ma: IOEither) => IO /** * 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: ( onLeft: (e: E) => B, onRight: (a: A) => C ) => (ma: IOEither) => IO /** * 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: ( onLeft: (e: E) => IO, onRight: (a: A) => IO ) => (ma: IOEither) => IO /** * Alias of [`matchE`](#matche). * * @category pattern matching * @since 2.0.0 */ export declare const fold: ( onLeft: (e: E) => I.IO, onRight: (a: A) => I.IO ) => (ma: IOEither) => I.IO /** * 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: ( onLeft: (e: E) => IO, onRight: (a: A) => IO ) => (ma: IOEither) => IO /** * Alias of [`matchEW`](#matchew). * * @category pattern matching * @since 2.10.0 */ export declare const foldW: ( onLeft: (e: E) => I.IO, onRight: (a: A) => I.IO ) => (ma: IOEither) => I.IO /** * @category error handling * @since 2.0.0 */ export declare const getOrElse: (onLeft: (e: E) => IO) => (ma: IOEither) => IO /** * 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: (onLeft: (e: E) => IO) => (ma: IOEither) => IO /** * 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: (f: Lazy, onThrow: (reason: unknown) => E) => IOEither /** * Converts a function that may throw to one returning a `IOEither`. * * @category interop * @since 2.10.0 */ export declare const tryCatchK: ( f: (...a: A) => B, onThrow: (reason: unknown) => E ) => (...a: A) => IOEither /** * @category conversions * @since 2.10.0 */ export declare const toUnion: (fa: IOEither) => IO /** * @category error handling * @since 2.0.0 */ export declare const orElse: (onLeft: (e: E1) => IOEither) => (ma: IOEither) => IOEither /** * 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: ( onLeft: (e: E1) => IOEither ) => (ma: IOEither) => IOEither /** * @category error handling * @since 2.11.0 */ export declare const orElseFirst: (onLeft: (e: E) => IOEither) => (ma: IOEither) => IOEither /** * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category error handling * @since 2.11.0 */ export declare const orElseFirstW: ( onLeft: (e: E1) => IOEither ) => (ma: IOEither) => IOEither /** * @category error handling * @since 2.12.0 */ export declare const orElseFirstIOK: (onLeft: (e: E) => IO) => (ma: IOEither) => IOEither /** * @category error handling * @since 2.11.0 */ export declare const orLeft: (onLeft: (e: E1) => IO) => (fa: IOEither) => IOEither /** * @since 2.0.0 */ export declare const swap: (ma: IOEither) => IOEither /** * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F) => F` 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: (f: (a: A) => B) => (fa: IOEither) => IOEither /** * Map a pair of functions over the two type arguments of the bifunctor. * * @category mapping * @since 2.0.0 */ export declare const bimap: (f: (e: E) => G, g: (a: A) => B) => (fa: IOEither) => IOEither /** * Map a function over the first type argument of a bifunctor. * * @category error handling * @since 2.0.0 */ export declare const mapLeft: (f: (e: E) => G) => (fa: IOEither) => IOEither /** * @since 2.0.0 */ export declare const ap: (fa: IOEither) => (fab: IOEither B>) => IOEither /** * 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: ( fa: IOEither ) => (fab: IOEither B>) => IOEither /** * @category constructors * @since 2.8.5 */ export declare const of: (a: A) => IOEither /** * Composes computations in sequence, using the return value of one computation to determine the next computation. * * @category sequencing * @since 2.0.0 */ export declare const chain: (f: (a: A) => IOEither) => (ma: IOEither) => IOEither /** * Less strict version of [`chain`](#chain). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category sequencing * @since 2.6.0 */ export declare const chainW: ( f: (a: A) => IOEither ) => (ma: IOEither) => IOEither /** * 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: (mma: IOEither>) => IOEither /** * @category sequencing * @since 2.0.0 */ export declare const flatten: (mma: IOEither>) => IOEither /** * 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: (that: Lazy>) => (fa: IOEither) => IOEither /** * 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: (that: Lazy>) => (fa: IOEither) => IOEither /** * @since 2.7.0 */ export declare const throwError: MonadThrow2['throwError'] /** * @category type lambdas * @since 2.0.0 */ export declare const URI = 'IOEither' /** * @category type lambdas * @since 2.0.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind2 { readonly [URI]: IOEither } } /** * 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(S: Semigroup): Applicative2C /** * 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(S: Semigroup): Alt2C /** * @category filtering * @since 2.10.0 */ export declare const getCompactable: (M: Monoid) => Compactable2C<'IOEither', E> /** * @category filtering * @since 2.1.0 */ export declare function getFilterable(M: Monoid): Filterable2C /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor2 /** * @category mapping * @since 2.10.0 */ export declare const flap: (a: A) => (fab: IOEither B>) => IOEither /** * @category instances * @since 2.10.0 */ export declare const Pointed: Pointed2 /** * @category instances * @since 2.7.0 */ export declare const Bifunctor: Bifunctor2 /** * Runs computations in parallel. * * @category instances * @since 2.10.0 */ export declare const ApplyPar: Apply2 /** * Combine two effectful actions, keeping only the result of the first. * * @since 2.0.0 */ export declare const apFirst: (second: IOEither) => (first: IOEither) => IOEither /** * 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: ( second: IOEither ) => (first: IOEither) => IOEither /** * Combine two effectful actions, keeping only the result of the second. * * @since 2.0.0 */ export declare const apSecond: (second: IOEither) => (first: IOEither) => IOEither /** * 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: ( second: IOEither ) => (first: IOEither) => IOEither /** * Runs computations in parallel. * * @category instances * @since 2.8.4 */ export declare const ApplicativePar: Applicative2 /** * Runs computations sequentially. * * @category instances * @since 2.8.4 */ export declare const ApplicativeSeq: Applicative2 /** * @category instances * @since 2.10.0 */ export declare const Chain: Chain2 /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad2 /** * 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 sequencing * @since 2.0.0 */ export declare const chainFirst: (f: (a: A) => IOEither) => (ma: IOEither) => IOEither /** * Less strict version of [`chainFirst`](#chainfirst). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category sequencing * @since 2.8.0 */ export declare const chainFirstW: ( f: (a: A) => IOEither ) => (ma: IOEither) => IOEither /** * @category instances * @since 2.7.0 */ export declare const Alt: Alt2 /** * @category instances * @since 2.7.0 */ export declare const MonadIO: MonadIO2 /** * @category instances * @since 2.7.0 */ export declare const MonadThrow: MonadThrow2 /** * @category instances * @since 2.10.0 */ export declare const FromIO: FromIO2 /** * @category lifting * @since 2.10.0 */ export declare const fromIOK: , B>( f: (...a: A) => I.IO ) => (...a: A) => IOEither /** * @category sequencing * @since 2.10.0 */ export declare const chainIOK: (f: (a: A) => I.IO) => (first: IOEither) => IOEither /** * @category sequencing * @since 2.10.0 */ export declare const chainFirstIOK: (f: (a: A) => I.IO) => (first: IOEither) => IOEither /** * @category instances * @since 2.10.0 */ export declare const FromEither: FromEither2 /** * @category conversions * @since 2.0.0 */ export declare const fromOption: (onNone: Lazy) => (fa: Option) => IOEither /** * @category lifting * @since 2.10.0 */ export declare const fromOptionK: ( onNone: Lazy ) => , B>(f: (...a: A) => Option) => (...a: A) => IOEither /** * @category sequencing * @since 2.10.0 */ export declare const chainOptionK: ( onNone: Lazy ) => (f: (a: A) => Option) => (ma: IOEither) => IOEither /** * @category sequencing * @since 2.4.0 */ export declare const chainEitherK: (f: (a: A) => E.Either) => (ma: IOEither) => IOEither /** * Less strict version of [`chainEitherK`](#chaineitherk). * * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category sequencing * @since 2.6.1 */ export declare const chainEitherKW: ( f: (a: A) => Either ) => (ma: IOEither) => IOEither /** * @category sequencing * @since 2.12.0 */ export declare const chainFirstEitherK: (f: (a: A) => E.Either) => (ma: IOEither) => IOEither /** * The `W` suffix (short for **W**idening) means that the error types will be merged. * * @category sequencing * @since 2.12.0 */ export declare const chainFirstEitherKW: ( f: (a: A) => E.Either ) => (ma: IOEither) => IOEither /** * @category lifting * @since 2.0.0 */ export declare const fromPredicate: { (refinement: Refinement, onFalse: (a: A) => E): (a: A) => IOEither (predicate: Predicate, onFalse: (a: A) => E): (b: B) => IOEither (predicate: Predicate, onFalse: (a: A) => E): (a: A) => IOEither } /** * @category filtering * @since 2.0.0 */ export declare const filterOrElse: { (refinement: Refinement, onFalse: (a: A) => E): (ma: IOEither) => IOEither (predicate: Predicate, onFalse: (a: A) => E): (mb: IOEither) => IOEither (predicate: Predicate, onFalse: (a: A) => E): (ma: IOEither) => IOEither } /** * 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: { (refinement: Refinement, onFalse: (a: A) => E2): ( ma: IOEither ) => IOEither (predicate: Predicate, onFalse: (a: A) => E2): ( mb: IOEither ) => IOEither (predicate: Predicate, onFalse: (a: A) => E2): (ma: IOEither) => IOEither } /** * @category lifting * @since 2.4.0 */ export declare const fromEitherK: , B>( f: (...a: A) => E.Either ) => (...a: A) => IOEither /** * 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: ( acquire: IOEither, use: (a: A) => IOEither, release: (a: A, e: E.Either) => IOEither ) => IOEither /** * 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: ( acquire: IOEither, use: (a: A) => IOEither, release: (a: A, e: E.Either) => IOEither ) => IOEither /** * @category do notation * @since 2.9.0 */ export declare const Do: IOEither /** * @category do notation * @since 2.8.0 */ export declare const bindTo: ( name: N ) => (fa: IOEither) => IOEither declare const let_: ( name: Exclude, f: (a: A) => B ) => (fa: IOEither) => IOEither export { /** * @category do notation * @since 2.13.0 */ let_ as let } /** * @category do notation * @since 2.8.0 */ export declare const bind: ( name: Exclude, f: (a: A) => IOEither ) => (ma: IOEither) => IOEither /** * 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: ( name: Exclude, f: (a: A) => IOEither ) => (fa: IOEither) => 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: ( name: Exclude, fb: IOEither ) => (fa: IOEither) => IOEither /** * 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: ( name: Exclude, fb: IOEither ) => (fa: IOEither) => 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 /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativePar)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndex: ( f: (index: number, a: A) => IOEither ) => (as: ReadonlyNonEmptyArray) => IOEither> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativePar)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndex: ( f: (index: number, a: A) => IOEither ) => (as: readonly A[]) => IOEither /** * Equivalent to `ReadonlyNonEmptyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyNonEmptyArrayWithIndexSeq: ( f: (index: number, a: A) => IOEither ) => (as: ReadonlyNonEmptyArray) => IOEither> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.11.0 */ export declare const traverseReadonlyArrayWithIndexSeq: ( f: (index: number, a: A) => IOEither ) => (as: readonly A[]) => IOEither /** * Equivalent to `ReadonlyArray#traverseWithIndex(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArrayWithIndex: ( f: (index: number, a: A) => IOEither ) => (as: ReadonlyArray) => IOEither> /** * Equivalent to `ReadonlyArray#traverse(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const traverseArray: ( f: (a: A) => IOEither ) => (as: readonly A[]) => IOEither /** * Equivalent to `ReadonlyArray#sequence(Applicative)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceArray: (arr: ReadonlyArray>) => IOEither> /** * Equivalent to `ReadonlyArray#traverseWithIndex(ApplicativeSeq)`. * * @category traversing * @since 2.9.0 */ export declare const traverseSeqArrayWithIndex: ( f: (index: number, a: A) => IOEither ) => (as: ReadonlyArray) => IOEither> /** * Equivalent to `ReadonlyArray#traverse(ApplicativeSeq)`. * * @category traversing * @since 2.9.0 */ export declare const traverseSeqArray: ( f: (a: A) => IOEither ) => (as: readonly A[]) => IOEither /** * Equivalent to `ReadonlyArray#sequence(ApplicativeSeq)`. * * @category traversing * @since 2.9.0 */ export declare const sequenceSeqArray: (arr: ReadonlyArray>) => IOEither> /** * Use [`ApplicativePar`](#applicativepar) instead * * @category zone of death * @since 2.7.0 * @deprecated */ export declare const Applicative: Applicative2 /** * 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 & Bifunctor2 & Alt2 & MonadIO2 & MonadThrow2 /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplySemigroup: (S: Semigroup) => Semigroup> /** * Use [`getApplicativeMonoid`](./Applicative.ts.html#getapplicativemonoid) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getApplyMonoid: (M: Monoid) => Monoid> /** * Use [`getApplySemigroup`](./Apply.ts.html#getapplysemigroup) instead. * * @category zone of death * @since 2.0.0 * @deprecated */ export declare const getSemigroup: (S: Semigroup) => Semigroup> /** * Use [`getApplicativeIOValidation`](#getapplicativeiovalidation) and [`getAltIOValidation`](#getaltiovalidation). * * @category zone of death * @since 2.0.0 * @deprecated */ export declare function getIOValidation( SE: Semigroup ): Monad2C & Bifunctor2 & Alt2C & MonadIO2C & MonadThrow2C