Exit
Constructors
Signature
declare const all: <A, E>(
exits: Iterable<Exit<A, E>>,
options?: {
readonly parallel?: boolean;
},
) => Option.Option<Exit<Array<A>, E>>;Constructs a new Exit.Failure from the specified unrecoverable defect.
Signature
declare const die: (defect: unknown) => Exit<never>;Constructs a new Exit.Failure from the specified recoverable error of type E.
Signature
declare const fail: <E>(error: E) => Exit<never, E>;Constructs a new Exit.Failure from the specified Cause of type E.
Signature
declare const failCause: <E>(cause: Cause.Cause<E>) => Exit<never, E>;Constructs a new Exit.Failure from the specified FiberId indicating that the Fiber running an Effect workflow was terminated due to interruption.
Signature
declare const interrupt: (fiberId: FiberId.FiberId) => Exit<never>;Constructs a new Exit.Success containing the specified value of type A.
Signature
declare const succeed: <A>(value: A) => Exit<A>;Conversions
fromEither
Converts an Either<R, L> into an Exit<R, L>.
Signature
declare const fromEither: <R, L>(either: Either.Either<R, L>) => Exit<R, L>;fromOption
Converts an Option<A> into an Exit<void, A>.
Signature
declare const fromOption: <A>(option: Option.Option<A>) => Exit<A, void>;Elements
Executes the predicate on the value of the specified exit if it is a Success, otherwise returns false.
Signature
declare const exists: {
<A, B>(refinement: Refinement<NoInfer<A>, B>): <E>(self: Exit<A, E>) => self is Exit<B, never>;
<A>(predicate: Predicate<NoInfer<A>>): <E>(self: Exit<A, E>) => boolean;
<A, E, B>(self: Exit<A, E>, refinement: Refinement<A, B>): self is Exit<B, never>;
<A, E>(self: Exit<A, E>, predicate: Predicate<A>): boolean;
};Folding
Signature
declare const match: {
<E, A, Z1, Z2>(options: {
readonly onFailure: (cause: Cause.Cause<E>) => Z1;
readonly onSuccess: (a: A) => Z2;
}): (self: Exit<A, E>) => Z1 | Z2;
<A, E, Z1, Z2>(
self: Exit<A, E>,
options: {
readonly onFailure: (cause: Cause.Cause<E>) => Z1;
readonly onSuccess: (a: A) => Z2;
},
): Z1 | Z2;
};matchEffect
Signature
declare const matchEffect: {
<E, A2, E2, R, A, A3, E3, R2>(options: {
readonly onFailure: (cause: Cause.Cause<E>) => Effect.Effect<A2, E2, R>;
readonly onSuccess: (a: A) => Effect.Effect<A3, E3, R2>;
}): (self: Exit<A, E>) => Effect<A2 | A3, E2 | E3, R | R2>;
<A, E, A2, E2, R, A3, E3, R2>(
self: Exit<A, E>,
options: {
readonly onFailure: (cause: Cause.Cause<E>) => Effect.Effect<A2, E2, R>;
readonly onSuccess: (a: A) => Effect.Effect<A3, E3, R2>;
},
): Effect<A2 | A3, E2 | E3, R | R2>;
};Getters
causeOption
Returns a Some<Cause<E>> if the specified exit is a Failure, None otherwise.
Signature
declare const causeOption: <A, E>(self: Exit<A, E>) => Option.Option<Cause.Cause<E>>;Returns the A if specified exit is a Success, otherwise returns the alternate A value computed from the specified function which receives the Cause<E> of the exit Failure.
Signature
declare const getOrElse: {
<E, A2>(orElse: (cause: Cause<E>) => A2): <A>(self: Exit<A, E>) => A2 | A;
<A, E, A2>(self: Exit<A, E>, orElse: (cause: Cause<E>) => A2): A | A2;
};isInterrupted
Returns true if the specified exit is a Failure and the Cause of the failure was due to interruption, false otherwise.
Signature
declare const isInterrupted: <A, E>(self: Exit<A, E>) => boolean;Mapping
Maps the Success value of the specified exit to the provided constant value.
Signature
declare const as: {
<A2>(value: A2): <A, E>(self: Exit<A, E>) => Exit<A2, E>;
<A, E, A2>(self: Exit<A, E>, value: A2): Exit<A2, E>;
};Maps the Success value of the specified exit to a void.
Signature
declare const asVoid: <A, E>(self: Exit<A, E>) => Exit<void, E>;Maps over the Success value of the specified exit using the provided function.
Signature
declare const map: {
<A, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>;
<A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>;
};Maps over the Success and Failure cases of the specified exit using the provided functions.
Signature
declare const mapBoth: {
<E, A, E2, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>;
<A, E, E2, A2>(
self: Exit<A, E>,
options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
},
): Exit<A2, E2>;
};Maps over the error contained in the Failure of the specified exit using the provided function.
Signature
declare const mapError: {
<E, E2>(f: (e: E) => E2): <A>(self: Exit<A, E>) => Exit<A, E2>;
<A, E, E2>(self: Exit<A, E>, f: (e: E) => E2): Exit<A, E2>;
};mapErrorCause
Maps over the Cause contained in the Failure of the specified exit using the provided function.
Signature
declare const mapErrorCause: {
<E, E2>(f: (cause: Cause<E>) => Cause<E2>): <A>(self: Exit<A, E>) => Exit<A, E2>;
<E, A, E2>(self: Exit<A, E>, f: (cause: Cause<E>) => Cause<E2>): Exit<A, E2>;
};Models
An Exit<A, E = never> describes the result of a executing an Effect workflow.
There are two possible values for an Exit<A, E>: - Exit.Success contain a success value of type A - Exit.Failure contains a failure Cause of type E
Signature
type Exit<A, E = never> = Success<A, E> | Failure<A, E>;Signature
interface ExitUnify<
A extends {
[typeSymbol]?: any;
},
> extends EffectUnify<A> {
Exit?: () => A[typeof typeSymbol] extends Exit<A0, E0> | _ ? Exit<A0, E0> : never;
}ExitUnifyIgnore interface
Signature
interface ExitUnifyIgnore extends EffectUnifyIgnore {
Effect?: true;
}Represents a failed Effect workflow containing the Cause of the failure of type E.
Signature
interface Failure<out A, out E> extends Effect<A, E>, Pipeable, Inspectable {
readonly _op: "Failure";
readonly _tag: "Failure";
[ignoreSymbol]?: ExitUnifyIgnore;
[typeSymbol]?: unknown;
[unifySymbol]?: ExitUnify<Failure<A, E>>;
readonly cause: Cause<E>;
}Represents a successful Effect workflow and containing the returned value of type A.
Signature
interface Success<out A, out E> extends Effect<A, E>, Pipeable, Inspectable {
readonly _op: "Success";
readonly _tag: "Success";
[ignoreSymbol]?: ExitUnifyIgnore;
[typeSymbol]?: unknown;
[unifySymbol]?: ExitUnify<Success<A, E>>;
readonly value: A;
}Other
Refinements
Returns true if the specified value is an Exit, false otherwise.
Signature
declare const isExit: (u: unknown) => u is Exit<unknown, unknown>;Returns true if the specified Exit is a Failure, false otherwise.
Signature
declare const isFailure: <A, E>(self: Exit<A, E>) => self is Failure<A, E>;Returns true if the specified Exit is a Success, false otherwise.
Signature
declare const isSuccess: <A, E>(self: Exit<A, E>) => self is Success<A, E>;Sequencing
Signature
declare const flatMap: {
<A, A2, E2>(f: (a: A) => Exit<A2, E2>): <E>(self: Exit<A, E>) => Exit<A2, E2 | E>;
<A, E, E2, A2>(self: Exit<A, E>, f: (a: A) => Exit<A2, E2>): Exit<A2, E | E2>;
};flatMapEffect
Signature
declare const flatMapEffect: {
<A, E, A2, E2, R>(
f: (a: A) => Effect<Exit<A2, E>, E2, R>,
): (self: Exit<A, E>) => Effect<Exit<A2, E>, E2, R>;
<A, E, A2, E2, R>(
self: Exit<A, E>,
f: (a: A) => Effect<Exit<A2, E>, E2, R>,
): Effect<Exit<A2, E>, E2, R>;
};Signature
declare const flatten: <A, E, E2>(self: Exit<Exit<A, E>, E2>) => Exit<A, E | E2>;Traversing
forEachEffect
Signature
declare const forEachEffect: {
<A, B, E2, R>(
f: (a: A) => Effect<B, E2, R>,
): <E>(self: Exit<A, E>) => Effect<Exit<B, E2 | E>, never, R>;
<A, E, B, E2, R>(
self: Exit<A, E>,
f: (a: A) => Effect<B, E2, R>,
): Effect<Exit<B, E | E2>, never, R>;
};Zipping
Sequentially zips the this result with the specified result or else returns the failed Cause<E | E2>.
Signature
declare const zip: {
<A2, E2>(that: Exit<A2, E2>): <A, E>(self: Exit<A, E>) => Exit<[A, A2], E2 | E>;
<A, E, A2, E2>(self: Exit<A, E>, that: Exit<A2, E2>): Exit<[A, A2], E | E2>;
};Sequentially zips the this result with the specified result discarding the second element of the tuple or else returns the failed Cause<E | E2>.
Signature
declare const zipLeft: {
<A2, E2>(that: Exit<A2, E2>): <A, E>(self: Exit<A, E>) => Exit<A, E2 | E>;
<A, E, A2, E2>(self: Exit<A, E>, that: Exit<A2, E2>): Exit<A, E | E2>;
};Parallelly zips the this result with the specified result or else returns the failed Cause<E | E2>.
Signature
declare const zipPar: {
<A2, E2>(that: Exit<A2, E2>): <A, E>(self: Exit<A, E>) => Exit<[A, A2], E2 | E>;
<A, E, A2, E2>(self: Exit<A, E>, that: Exit<A2, E2>): Exit<[A, A2], E | E2>;
};zipParLeft
Parallelly zips the this result with the specified result discarding the second element of the tuple or else returns the failed Cause<E | E2>.
Signature
declare const zipParLeft: {
<A2, E2>(that: Exit<A2, E2>): <A, E>(self: Exit<A, E>) => Exit<A, E2 | E>;
<A, E, A2, E2>(self: Exit<A, E>, that: Exit<A2, E2>): Exit<A, E | E2>;
};zipParRight
Parallelly zips the this result with the specified result discarding the first element of the tuple or else returns the failed Cause<E | E2>.
Signature
declare const zipParRight: {
<A2, E2>(that: Exit<A2, E2>): <A, E>(self: Exit<A, E>) => Exit<A2, E2 | E>;
<A, E, A2, E2>(self: Exit<A, E>, that: Exit<A2, E2>): Exit<A2, E | E2>;
};Sequentially zips the this result with the specified result discarding the first element of the tuple or else returns the failed Cause<E | E2>.
Signature
declare const zipRight: {
<A2, E2>(that: Exit<A2, E2>): <A, E>(self: Exit<A, E>) => Exit<A2, E2 | E>;
<A, E, A2, E2>(self: Exit<A, E>, that: Exit<A2, E2>): Exit<A2, E | E2>;
};Zips this exit together with that exit using the specified combination functions.
Signature
declare const zipWith: {
<B, E2, A, C, E>(
that: Exit<B, E2>,
options: {
readonly onFailure: (cause: Cause.Cause<E>, cause2: Cause.Cause<E2>) => Cause.Cause<any>;
readonly onSuccess: (a: A, b: B) => C;
},
): (self: Exit<A, E>) => Exit<C, any>;
<A, E, B, E2, C>(
self: Exit<A, E>,
that: Exit<B, E2>,
options: {
readonly onFailure: (cause: Cause.Cause<E>, cause2: Cause.Cause<E2>) => Cause.Cause<E | E2>;
readonly onSuccess: (a: A, b: B) => C;
},
): Exit<C, E | E2>;
};
Collects all of the specified exit values into a
Some<Exit<List<A>, E>>. If the provided iterable contains no elements,Nonewill be returned.