/** * `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`. * * @since 2.0.0 */ import { Alt2, Alt2C } from './Alt' import { Applicative2, Applicative2C } from './Applicative' import { Bifunctor2 } from './Bifunctor' import * as E from './Either' import { Filterable2C } from './Filterable' import { Lazy, Predicate, Refinement } 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 { 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 /** * Derivable from `MonadThrow`. * * @category constructors * @since 2.0.0 */ export declare const fromEither: (ma: E.Either) => IOEither /** * Derivable from `MonadThrow`. * * @category constructors * @since 2.0.0 */ export declare const fromOption: (onNone: Lazy) => (ma: Option) => IOEither /** * Derivable from `MonadThrow`. * * @category constructors * @since 2.0.0 */ export declare const fromPredicate: { (refinement: Refinement, onFalse: (a: A) => E): (a: A) => IOEither (predicate: Predicate, onFalse: (a: A) => E): (a: A) => IOEither } /** * Constructs a new `IOEither` from a function that performs a side effect and might throw * * @category constructors * @since 2.0.0 */ export declare function tryCatch(f: Lazy, onError: (reason: unknown) => E): IOEither /** * @category destructors * @since 2.0.0 */ export declare const fold: (onLeft: (e: E) => IO, onRight: (a: A) => IO) => (ma: IOEither) => IO /** * Less strict version of [`getOrElse`](#getOrElse). * * @category destructors * @since 2.6.0 */ export declare const getOrElseW: (onLeft: (e: E) => I.IO) => (ma: IOEither) => I.IO /** * @category destructors * @since 2.0.0 */ export declare const getOrElse: (onLeft: (e: E) => IO) => (ma: IOEither) => IO /** * @category combinators * @since 2.0.0 */ export declare const orElse: (onLeft: (e: E) => IOEither) => (ma: IOEither) => IOEither /** * @category combinators * @since 2.0.0 */ export declare const swap: (ma: IOEither) => IOEither /** * Less strict version of [`filterOrElse`](#filterOrElse). * * @since 2.9.0 */ export declare const filterOrElseW: { (refinement: Refinement, onFalse: (a: A) => E2): ( ma: IOEither ) => IOEither (predicate: Predicate, onFalse: (a: A) => E2): (ma: IOEither) => IOEither } /** * Derivable from `MonadThrow`. * * @category combinators * @since 2.0.0 */ export declare const filterOrElse: { (refinement: Refinement, onFalse: (a: A) => E): (ma: IOEither) => IOEither (predicate: Predicate, onFalse: (a: A) => E): (ma: IOEither) => IOEither } /** * @category combinators * @since 2.4.0 */ export declare function fromEitherK, B>( f: (...a: A) => Either ): (...a: A) => IOEither /** * Less strict version of [`chainEitherK`](#chainEitherK). * * @category combinators * @since 2.6.1 */ export declare const chainEitherKW: ( f: (a: A) => Either ) => (ma: IOEither) => IOEither /** * @category combinators * @since 2.4.0 */ export declare const chainEitherK: (f: (a: A) => Either) => (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 Functor * @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 Bifunctor * @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 Bifunctor * @since 2.0.0 */ export declare const mapLeft: (f: (e: E) => G) => (fa: IOEither) => IOEither /** * Less strict version of [`ap`](#ap). * * @category Apply * @since 2.8.0 */ export declare const apW: (fa: IOEither) => (fab: IOEither B>) => IOEither /** * Apply a function to an argument under a type constructor. * * @category Apply * @since 2.0.0 */ export declare const ap: (fa: IOEither) => (fab: IOEither B>) => IOEither /** * Combine two effectful actions, keeping only the result of the first. * * Derivable from `Apply`. * * @category combinators * @since 2.0.0 */ export declare const apFirst: (fb: IOEither) => (fa: IOEither) => IOEither /** * Combine two effectful actions, keeping only the result of the second. * * Derivable from `Apply`. * * @category combinators * @since 2.0.0 */ export declare const apSecond: (fb: IOEither) => (fa: IOEither) => IOEither /** * Wrap a value into the type constructor. * * Equivalent to [`right`](#right). * * @category Applicative * @since 2.8.5 */ export declare const of: Applicative2['of'] /** * Less strict version of [`chain`](#chain). * * @category Monad * @since 2.6.0 */ export declare const chainW: (f: (a: A) => IOEither) => (ma: IOEither) => IOEither /** * Composes computations in sequence, using the return value of one computation to determine the next computation. * * @category Monad * @since 2.0.0 */ export declare const chain: (f: (a: A) => IOEither) => (ma: IOEither) => IOEither /** * Less strict version of [`chainFirst`](#chainFirst). * * Derivable from `Monad`. * * @category combinators * @since 2.8.0 */ export declare const chainFirstW: ( f: (a: A) => IOEither ) => (ma: IOEither) => IOEither /** * Composes computations in sequence, using the return value of one computation to determine the next computation and * keeping only the result of the first. * * Derivable from `Monad`. * * @category combinators * @since 2.0.0 */ export declare const chainFirst: (f: (a: A) => IOEither) => (ma: IOEither) => IOEither /** * Derivable from `Monad`. * * @category combinators * @since 2.0.0 */ export declare const flatten: (mma: IOEither>) => IOEither /** * Less strict version of [`alt`](#alt). * * @category Alt * @since 2.9.0 */ export declare const altW: ( that: Lazy> ) => (fa: IOEither) => IOEither /** * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to * types of kind `* -> *`. * * @category Alt * @since 2.0.0 */ export declare const alt: (that: Lazy>) => (fa: IOEither) => IOEither /** * @category MonadIO * @since 2.7.0 */ export declare const fromIO: MonadIO2['fromIO'] /** * @category MonadThrow * @since 2.7.0 */ export declare const throwError: MonadThrow2['throwError'] /** * @category instances * @since 2.0.0 */ export declare const URI = 'IOEither' /** * @category instances * @since 2.0.0 */ export declare type URI = typeof URI declare module './HKT' { interface URItoKind2 { readonly [URI]: IOEither } } /** * Semigroup returning the left-most non-`Left` value. If both operands are `Right`s then the inner values are * concatenated using the provided `Semigroup` * * @category instances * @since 2.0.0 */ export declare function getSemigroup(S: Semigroup): Semigroup> /** * Semigroup returning the left-most `Left` value. If both operands are `Right`s then the inner values * are concatenated using the provided `Semigroup` * * @category instances * @since 2.0.0 */ export declare function getApplySemigroup(S: Semigroup): Semigroup> /** * @category instances * @since 2.0.0 */ export declare function getApplyMonoid(M: Monoid): Monoid> /** * @category instances * @since 2.7.0 */ export declare function getApplicativeIOValidation(SE: Semigroup): Applicative2C /** * @category instances * @since 2.7.0 */ export declare function getAltIOValidation(SE: Semigroup): Alt2C /** * @category instances * @since 2.0.0 */ export declare function getIOValidation( SE: Semigroup ): Monad2C & Bifunctor2 & Alt2C & MonadIO2C & MonadThrow2C /** * @category instances * @since 2.1.0 */ export declare function getFilterable(M: Monoid): Filterable2C /** * @category instances * @since 2.7.0 */ export declare const Functor: Functor2 /** * @category instances * @since 2.7.0 */ export declare const Bifunctor: Bifunctor2 /** * @category instances * @since 2.8.4 */ export declare const ApplicativePar: Applicative2 /** * @category instances * @since 2.8.4 */ export declare const ApplicativeSeq: Applicative2 /** * Use `ApplicativePar` instead * * @since 2.7.0 * @category instances * @deprecated */ export declare const Applicative: Applicative2 /** * @category instances * @since 2.7.0 */ export declare const Monad: Monad2 /** * @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.0.0 */ export declare const ioEither: Monad2 & Bifunctor2 & Alt2 & MonadIO2 & MonadThrow2 /** * 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` * * Derivable from `MonadThrow`. * * @since 2.0.0 */ export declare const bracket: ( acquire: IOEither, use: (a: A) => IOEither, release: (a: A, e: E.Either) => IOEither ) => IOEither /** * @since 2.9.0 */ export declare const Do: IOEither /** * @since 2.8.0 */ export declare const bindTo: (name: N) => (fa: IOEither) => IOEither /** * @since 2.8.0 */ export declare const bindW: ( name: Exclude, f: (a: A) => IOEither ) => (fa: IOEither) => IOEither /** * @since 2.8.0 */ export declare const bind: ( name: Exclude, f: (a: A) => IOEither ) => ( fa: IOEither ) => IOEither< E, { [K in keyof A | N]: K extends keyof A ? A[K] : B } > /** * @since 2.8.0 */ export declare const apSW: ( name: Exclude, fb: IOEither ) => (fa: IOEither) => IOEither /** * @since 2.8.0 */ export declare const apS: ( name: Exclude, fb: IOEither ) => ( fa: IOEither ) => IOEither< E, { [K in keyof A | N]: K extends keyof A ? A[K] : B } > /** * @since 2.9.0 */ export declare const traverseArrayWithIndex: ( f: (index: number, a: A) => IOEither ) => (arr: ReadonlyArray) => IOEither> /** * @since 2.9.0 */ export declare const traverseArray: ( f: (a: A) => IOEither ) => (arr: ReadonlyArray) => IOEither> /** * * @since 2.9.0 */ export declare const sequenceArray: (arr: ReadonlyArray>) => IOEither> /** * @since 2.9.0 */ export declare const traverseSeqArrayWithIndex: ( f: (index: number, a: A) => IOEither ) => (arr: ReadonlyArray) => IOEither> /** * @since 2.9.0 */ export declare const traverseSeqArray: ( f: (a: A) => IOEither ) => (arr: ReadonlyArray) => IOEither> /** * @since 2.9.0 */ export declare const sequenceSeqArray: (arr: ReadonlyArray>) => IOEither>