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
.
Added in v2.0.0
Identifies an associative operation on a type constructor. It is similar to Semigroup
, except that it applies to
types of kind * -> *
.
Signature
export declare const alt: <E, A>(that: Lazy<IOEither<E, A>>) => (fa: IOEither<E, A>) => IOEither<E, A>
Added in v2.0.0
Less strict version of alt
.
Signature
export declare const altW: <E2, B>(
that: Lazy<IOEither<E2, B>>
) => <E1, A>(fa: IOEither<E1, A>) => IOEither<E2 | E1, B | A>
Added in v2.9.0
Wrap a value into the type constructor.
Equivalent to right
.
Signature
export declare const of: <E, A>(a: A) => IOEither<E, A>
Added in v2.8.5
Apply a function to an argument under a type constructor.
Signature
export declare const ap: <E, A>(fa: IOEither<E, A>) => <B>(fab: IOEither<E, (a: A) => B>) => IOEither<E, B>
Added in v2.0.0
Less strict version of ap
.
Signature
export declare const apW: <D, A>(fa: IOEither<D, A>) => <E, B>(fab: IOEither<E, (a: A) => B>) => IOEither<D | E, B>
Added in v2.8.0
Map a pair of functions over the two type arguments of the bifunctor.
Signature
export declare const bimap: <E, G, A, B>(f: (e: E) => G, g: (a: A) => B) => (fa: IOEither<E, A>) => IOEither<G, B>
Added in v2.0.0
Map a function over the first type argument of a bifunctor.
Signature
export declare const mapLeft: <E, G>(f: (e: E) => G) => <A>(fa: IOEither<E, A>) => IOEither<G, A>
Added in v2.0.0
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.
Signature
export declare const map: <A, B>(f: (a: A) => B) => <E>(fa: IOEither<E, A>) => IOEither<E, B>
Added in v2.0.0
Composes computations in sequence, using the return value of one computation to determine the next computation.
Signature
export declare const chain: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>
Added in v2.0.0
Less strict version of chain
.
Signature
export declare const chainW: <D, A, B>(f: (a: A) => IOEither<D, B>) => <E>(ma: IOEither<E, A>) => IOEither<D | E, B>
Added in v2.6.0
Signature
export declare const fromIO: <E, A>(fa: I.IO<A>) => IOEither<E, A>
Added in v2.7.0
Signature
export declare const throwError: <E, A>(e: E) => IOEither<E, A>
Added in v2.7.0
Combine two effectful actions, keeping only the result of the first.
Derivable from Apply
.
Signature
export declare const apFirst: <E, B>(fb: IOEither<E, B>) => <A>(fa: IOEither<E, A>) => IOEither<E, A>
Added in v2.0.0
Combine two effectful actions, keeping only the result of the second.
Derivable from Apply
.
Signature
export declare const apSecond: <E, B>(fb: IOEither<E, B>) => <A>(fa: IOEither<E, A>) => IOEither<E, B>
Added in v2.0.0
Signature
export declare const chainEitherK: <E, A, B>(f: (a: A) => E.Either<E, B>) => (ma: IOEither<E, A>) => IOEither<E, B>
Added in v2.4.0
Less strict version of chainEitherK
.
Signature
export declare const chainEitherKW: <E, A, B>(
f: (a: A) => E.Either<E, B>
) => <D>(ma: IOEither<D, A>) => IOEither<E | D, B>
Added in v2.6.1
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
.
Signature
export declare const chainFirst: <E, A, B>(f: (a: A) => IOEither<E, B>) => (ma: IOEither<E, A>) => IOEither<E, A>
Added in v2.0.0
Less strict version of chainFirst
.
Derivable from Monad
.
Signature
export declare const chainFirstW: <D, A, B>(
f: (a: A) => IOEither<D, B>
) => <E>(ma: IOEither<E, A>) => IOEither<D | E, A>
Added in v2.8.0
Derivable from MonadThrow
.
Signature
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): (ma: IOEither<E, A>) => IOEither<E, A>
}
Added in v2.0.0
Derivable from Monad
.
Signature
export declare const flatten: <E, A>(mma: IOEither<E, IOEither<E, A>>) => IOEither<E, A>
Added in v2.0.0
Signature
export declare function fromEitherK<E, A extends ReadonlyArray<unknown>, B>(
f: (...a: A) => Either<E, B>
): (...a: A) => IOEither<E, B>
Added in v2.4.0
Signature
export declare const orElse: <E, A, M>(onLeft: (e: E) => IOEither<M, A>) => (ma: IOEither<E, A>) => IOEither<M, A>
Added in v2.0.0
Signature
export declare const swap: <E, A>(ma: IOEither<E, A>) => IOEither<A, E>
Added in v2.0.0
Derivable from MonadThrow
.
Signature
export declare const fromEither: <E, A>(ma: E.Either<E, A>) => IOEither<E, A>
Added in v2.0.0
Derivable from MonadThrow
.
Signature
export declare const fromOption: <E>(onNone: Lazy<E>) => <A>(ma: Option<A>) => IOEither<E, A>
Added in v2.0.0
Derivable from MonadThrow
.
Signature
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): (a: A) => IOEither<E, A>
}
Added in v2.0.0
Signature
export declare const left: <E = never, A = never>(l: E) => IOEither<E, A>
Added in v2.0.0
Signature
export declare const leftIO: <E = never, A = never>(me: I.IO<E>) => IOEither<E, A>
Added in v2.0.0
Signature
export declare const right: <E = never, A = never>(a: A) => IOEither<E, A>
Added in v2.0.0
Signature
export declare const rightIO: <E = never, A = never>(ma: I.IO<A>) => IOEither<E, A>
Added in v2.0.0
Constructs a new IOEither
from a function that performs a side effect and might throw
Signature
export declare function tryCatch<E, A>(f: Lazy<A>, onError: (reason: unknown) => E): IOEither<E, A>
Added in v2.0.0
Signature
export declare const fold: <E, A, B>(
onLeft: (e: E) => I.IO<B>,
onRight: (a: A) => I.IO<B>
) => (ma: IOEither<E, A>) => I.IO<B>
Added in v2.0.0
Signature
export declare const getOrElse: <E, A>(onLeft: (e: E) => I.IO<A>) => (ma: IOEither<E, A>) => I.IO<A>
Added in v2.0.0
Less strict version of getOrElse
.
Signature
export declare const getOrElseW: <E, B>(onLeft: (e: E) => I.IO<B>) => <A>(ma: IOEither<E, A>) => I.IO<B | A>
Added in v2.6.0
Signature
export declare const Alt: Alt2<'IOEither'>
Added in v2.7.0
Signature
export declare const ApplicativePar: Applicative2<'IOEither'>
Added in v2.8.4
Signature
export declare const ApplicativeSeq: Applicative2<'IOEither'>
Added in v2.8.4
Signature
export declare const Bifunctor: Bifunctor2<'IOEither'>
Added in v2.7.0
Signature
export declare const Functor: Functor2<'IOEither'>
Added in v2.7.0
Signature
export declare const Monad: Monad2<'IOEither'>
Added in v2.7.0
Signature
export declare const MonadIO: MonadIO2<'IOEither'>
Added in v2.7.0
Signature
export declare const MonadThrow: MonadThrow2<'IOEither'>
Added in v2.7.0
Signature
export declare const URI: 'IOEither'
Added in v2.0.0
Signature
export type URI = typeof URI
Added in v2.0.0
Signature
export declare function getAltIOValidation<E>(SE: Semigroup<E>): Alt2C<URI, E>
Added in v2.7.0
Signature
export declare function getApplicativeIOValidation<E>(SE: Semigroup<E>): Applicative2C<URI, E>
Added in v2.7.0
Signature
export declare function getApplyMonoid<E, A>(M: Monoid<A>): Monoid<IOEither<E, A>>
Added in v2.0.0
Semigroup returning the left-most Left
value. If both operands are Right
s then the inner values
are concatenated using the provided Semigroup
Signature
export declare function getApplySemigroup<E, A>(S: Semigroup<A>): Semigroup<IOEither<E, A>>
Added in v2.0.0
Signature
export declare function getFilterable<E>(M: Monoid<E>): Filterable2C<URI, E>
Added in v2.1.0
Signature
export declare function getIOValidation<E>(
SE: Semigroup<E>
): Monad2C<URI, E> & Bifunctor2<URI> & Alt2C<URI, E> & MonadIO2C<URI, E> & MonadThrow2C<URI, E>
Added in v2.0.0
Semigroup returning the left-most non-Left
value. If both operands are Right
s then the inner values are
concatenated using the provided Semigroup
Signature
export declare function getSemigroup<E, A>(S: Semigroup<A>): Semigroup<IOEither<E, A>>
Added in v2.0.0
Signature
export declare const ioEither: Monad2<'IOEither'> &
Bifunctor2<'IOEither'> &
Alt2<'IOEither'> &
MonadIO2<'IOEither'> &
MonadThrow2<'IOEither'>
Added in v2.0.0
Use ApplicativePar
instead
Signature
export declare const Applicative: Applicative2<'IOEither'>
Added in v2.7.0
Signature
export interface IOEither<E, A> extends IO<Either<E, A>> {}
Added in v2.0.0
Signature
export declare const Do: IOEither<never, {}>
Added in v2.9.0
Signature
export declare const apS: <A, N extends string, E, B>(
name: Exclude<N, keyof A>,
fb: IOEither<E, B>
) => (fa: IOEither<E, A>) => IOEither<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.8.0
Signature
export declare const apSW: <A, N extends string, D, B>(
name: Exclude<N, keyof A>,
fb: IOEither<D, B>
) => <E>(fa: IOEither<E, A>) => IOEither<D | E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.8.0
Signature
export declare const bind: <N extends string, A, E, B>(
name: Exclude<N, keyof A>,
f: (a: A) => IOEither<E, B>
) => (fa: IOEither<E, A>) => IOEither<E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.8.0
Signature
export declare const bindTo: <N extends string>(name: N) => <E, A>(fa: IOEither<E, A>) => IOEither<E, { [K in N]: A }>
Added in v2.8.0
Signature
export declare const bindW: <N extends string, A, D, B>(
name: Exclude<N, keyof A>,
f: (a: A) => IOEither<D, B>
) => <E>(fa: IOEither<E, A>) => IOEither<D | E, { [K in N | keyof A]: K extends keyof A ? A[K] : B }>
Added in v2.8.0
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
.
Signature
export declare const bracket: <E, A, B>(
acquire: IOEither<E, A>,
use: (a: A) => IOEither<E, B>,
release: (a: A, e: E.Either<E, B>) => IOEither<E, void>
) => IOEither<E, B>
Added in v2.0.0
Less strict version of filterOrElse
.
Signature
export declare const filterOrElseW: {
<A, B extends A, E2>(refinement: Refinement<A, B>, onFalse: (a: A) => E2): <E1>(
ma: IOEither<E1, A>
) => IOEither<E2 | E1, B>
<A, E2>(predicate: Predicate<A>, onFalse: (a: A) => E2): <E1>(ma: IOEither<E1, A>) => IOEither<E2 | E1, A>
}
Added in v2.9.0
Signature
export declare const sequenceArray: <E, A>(arr: readonly IOEither<E, A>[]) => IOEither<E, readonly A[]>
Added in v2.9.0
Signature
export declare const sequenceSeqArray: <E, A>(arr: readonly IOEither<E, A>[]) => IOEither<E, readonly A[]>
Added in v2.9.0
Signature
export declare const traverseArray: <A, E, B>(
f: (a: A) => IOEither<E, B>
) => (arr: readonly A[]) => IOEither<E, readonly B[]>
Added in v2.9.0
Signature
export declare const traverseArrayWithIndex: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>
) => (arr: readonly A[]) => IOEither<E, readonly B[]>
Added in v2.9.0
Signature
export declare const traverseSeqArray: <A, E, B>(
f: (a: A) => IOEither<E, B>
) => (arr: readonly A[]) => IOEither<E, readonly B[]>
Added in v2.9.0
Signature
export declare const traverseSeqArrayWithIndex: <A, E, B>(
f: (index: number, a: A) => IOEither<E, B>
) => (arr: readonly A[]) => IOEither<E, readonly B[]>
Added in v2.9.0