/** * @since 2.0.0 */ import type * as Cause from "./Cause.js"; import type * as Effect from "./Effect.js"; import type * as Either from "./Either.js"; import type * as FiberId from "./FiberId.js"; import type { Inspectable } from "./Inspectable.js"; import type * as Option from "./Option.js"; import type { Pipeable } from "./Pipeable.js"; import type { Predicate, Refinement } from "./Predicate.js"; import type { NoInfer } from "./Types.js"; import type * as Unify from "./Unify.js"; /** * An `Exit` describes the result of a executing an `Effect` workflow. * * There are two possible values for an `Exit`: * - `Exit.Success` contain a success value of type `A` * - `Exit.Failure` contains a failure `Cause` of type `E` * * @since 2.0.0 * @category models */ export type Exit = Success | Failure; /** * Represents a failed `Effect` workflow containing the `Cause` of the failure * of type `E`. * * @since 2.0.0 * @category models */ export interface Failure extends Effect.Effect, Pipeable, Inspectable { readonly _tag: "Failure"; readonly _op: "Failure"; readonly cause: Cause.Cause; [Unify.typeSymbol]?: unknown; [Unify.unifySymbol]?: ExitUnify; [Unify.ignoreSymbol]?: ExitUnifyIgnore; } /** * @category models * @since 2.0.0 */ export interface ExitUnify extends Effect.EffectUnify { Exit?: () => A[Unify.typeSymbol] extends Exit | infer _ ? Exit : never; } /** * @category models * @since 2.0.0 */ export interface ExitUnifyIgnore extends Effect.EffectUnifyIgnore { Effect?: true; } /** * Represents a successful `Effect` workflow and containing the returned value * of type `A`. * * @since 2.0.0 * @category models */ export interface Success extends Effect.Effect, Pipeable, Inspectable { readonly _tag: "Success"; readonly _op: "Success"; readonly value: A; [Unify.typeSymbol]?: unknown; [Unify.unifySymbol]?: ExitUnify; [Unify.ignoreSymbol]?: ExitUnifyIgnore; } /** * Returns `true` if the specified value is an `Exit`, `false` otherwise. * * @since 2.0.0 * @category refinements */ export declare const isExit: (u: unknown) => u is Exit; /** * Returns `true` if the specified `Exit` is a `Failure`, `false` otherwise. * * @since 2.0.0 * @category refinements */ export declare const isFailure: (self: Exit) => self is Failure; /** * Returns `true` if the specified `Exit` is a `Success`, `false` otherwise. * * @since 2.0.0 * @category refinements */ export declare const isSuccess: (self: Exit) => self is Success; /** * Returns `true` if the specified exit is a `Failure` **and** the `Cause` of * the failure was due to interruption, `false` otherwise. * * @since 2.0.0 * @category getters */ export declare const isInterrupted: (self: Exit) => boolean; /** * Maps the `Success` value of the specified exit to the provided constant * value. * * @since 2.0.0 * @category mapping */ export declare const as: { /** * Maps the `Success` value of the specified exit to the provided constant * value. * * @since 2.0.0 * @category mapping */ (value: A2): (self: Exit) => Exit; /** * Maps the `Success` value of the specified exit to the provided constant * value. * * @since 2.0.0 * @category mapping */ (self: Exit, value: A2): Exit; }; /** * Maps the `Success` value of the specified exit to a void. * * @since 2.0.0 * @category mapping */ export declare const asVoid: (self: Exit) => Exit; /** * Returns a `Some>` if the specified exit is a `Failure`, `None` * otherwise. * * @since 2.0.0 * @category getters */ export declare const causeOption: (self: Exit) => Option.Option>; /** * Collects all of the specified exit values into a `Some, E>>`. If * the provided iterable contains no elements, `None` will be returned. * * @since 2.0.0 * @category constructors */ export declare const all: (exits: Iterable>, options?: { readonly parallel?: boolean | undefined; } | undefined) => Option.Option, E>>; /** * Constructs a new `Exit.Failure` from the specified unrecoverable defect. * * @since 2.0.0 * @category constructors */ export declare const die: (defect: unknown) => Exit; /** * Executes the predicate on the value of the specified exit if it is a * `Success`, otherwise returns `false`. * * @since 2.0.0 * @category elements */ export declare const exists: { /** * Executes the predicate on the value of the specified exit if it is a * `Success`, otherwise returns `false`. * * @since 2.0.0 * @category elements */ (refinement: Refinement, B>): (self: Exit) => self is Exit; /** * Executes the predicate on the value of the specified exit if it is a * `Success`, otherwise returns `false`. * * @since 2.0.0 * @category elements */ (predicate: Predicate>): (self: Exit) => boolean; /** * Executes the predicate on the value of the specified exit if it is a * `Success`, otherwise returns `false`. * * @since 2.0.0 * @category elements */ (self: Exit, refinement: Refinement): self is Exit; /** * Executes the predicate on the value of the specified exit if it is a * `Success`, otherwise returns `false`. * * @since 2.0.0 * @category elements */ (self: Exit, predicate: Predicate): boolean; }; /** * Constructs a new `Exit.Failure` from the specified recoverable error of type * `E`. * * @since 2.0.0 * @category constructors */ export declare const fail: (error: E) => Exit; /** * Constructs a new `Exit.Failure` from the specified `Cause` of type `E`. * * @since 2.0.0 * @category constructors */ export declare const failCause: (cause: Cause.Cause) => Exit; /** * @since 2.0.0 * @category sequencing */ export declare const flatMap: { /** * @since 2.0.0 * @category sequencing */ (f: (a: A) => Exit): (self: Exit) => Exit; /** * @since 2.0.0 * @category sequencing */ (self: Exit, f: (a: A) => Exit): Exit; }; /** * @since 2.0.0 * @category sequencing */ export declare const flatMapEffect: { /** * @since 2.0.0 * @category sequencing */ (f: (a: A) => Effect.Effect, E2, R>): (self: Exit) => Effect.Effect, E2, R>; /** * @since 2.0.0 * @category sequencing */ (self: Exit, f: (a: A) => Effect.Effect, E2, R>): Effect.Effect, E2, R>; }; /** * @since 2.0.0 * @category sequencing */ export declare const flatten: (self: Exit, E2>) => Exit; /** * @since 2.0.0 * @category traversing */ export declare const forEachEffect: { /** * @since 2.0.0 * @category traversing */ (f: (a: A) => Effect.Effect): (self: Exit) => Effect.Effect, never, R>; /** * @since 2.0.0 * @category traversing */ (self: Exit, f: (a: A) => Effect.Effect): Effect.Effect, never, R>; }; /** * Converts an `Either` into an `Exit`. * * @since 2.0.0 * @category conversions */ export declare const fromEither: (either: Either.Either) => Exit; /** * Converts an `Option` into an `Exit`. * * @since 2.0.0 * @category conversions */ export declare const fromOption: (option: Option.Option) => Exit; /** * Returns the `A` if specified exit is a `Success`, otherwise returns the * alternate `A` value computed from the specified function which receives the * `Cause` of the exit `Failure`. * * @since 2.0.0 * @category getters */ export declare const getOrElse: { /** * Returns the `A` if specified exit is a `Success`, otherwise returns the * alternate `A` value computed from the specified function which receives the * `Cause` of the exit `Failure`. * * @since 2.0.0 * @category getters */ (orElse: (cause: Cause.Cause) => A2): (self: Exit) => A2 | A; /** * Returns the `A` if specified exit is a `Success`, otherwise returns the * alternate `A` value computed from the specified function which receives the * `Cause` of the exit `Failure`. * * @since 2.0.0 * @category getters */ (self: Exit, orElse: (cause: Cause.Cause) => A2): A | A2; }; /** * Constructs a new `Exit.Failure` from the specified `FiberId` indicating that * the `Fiber` running an `Effect` workflow was terminated due to interruption. * * @since 2.0.0 * @category constructors */ export declare const interrupt: (fiberId: FiberId.FiberId) => Exit; /** * Maps over the `Success` value of the specified exit using the provided * function. * * @since 2.0.0 * @category mapping */ export declare const map: { /** * Maps over the `Success` value of the specified exit using the provided * function. * * @since 2.0.0 * @category mapping */ (f: (a: A) => B): (self: Exit) => Exit; /** * Maps over the `Success` value of the specified exit using the provided * function. * * @since 2.0.0 * @category mapping */ (self: Exit, f: (a: A) => B): Exit; }; /** * Maps over the `Success` and `Failure` cases of the specified exit using the * provided functions. * * @since 2.0.0 * @category mapping */ export declare const mapBoth: { /** * Maps over the `Success` and `Failure` cases of the specified exit using the * provided functions. * * @since 2.0.0 * @category mapping */ (options: { readonly onFailure: (e: E) => E2; readonly onSuccess: (a: A) => A2; }): (self: Exit) => Exit; /** * Maps over the `Success` and `Failure` cases of the specified exit using the * provided functions. * * @since 2.0.0 * @category mapping */ (self: Exit, options: { readonly onFailure: (e: E) => E2; readonly onSuccess: (a: A) => A2; }): Exit; }; /** * Maps over the error contained in the `Failure` of the specified exit using * the provided function. * * @since 2.0.0 * @category mapping */ export declare const mapError: { /** * Maps over the error contained in the `Failure` of the specified exit using * the provided function. * * @since 2.0.0 * @category mapping */ (f: (e: E) => E2): (self: Exit) => Exit; /** * Maps over the error contained in the `Failure` of the specified exit using * the provided function. * * @since 2.0.0 * @category mapping */ (self: Exit, f: (e: E) => E2): Exit; }; /** * Maps over the `Cause` contained in the `Failure` of the specified exit using * the provided function. * * @since 2.0.0 * @category mapping */ export declare const mapErrorCause: { /** * Maps over the `Cause` contained in the `Failure` of the specified exit using * the provided function. * * @since 2.0.0 * @category mapping */ (f: (cause: Cause.Cause) => Cause.Cause): (self: Exit) => Exit; /** * Maps over the `Cause` contained in the `Failure` of the specified exit using * the provided function. * * @since 2.0.0 * @category mapping */ (self: Exit, f: (cause: Cause.Cause) => Cause.Cause): Exit; }; /** * @since 2.0.0 * @category folding */ export declare const match: { /** * @since 2.0.0 * @category folding */ (options: { readonly onFailure: (cause: Cause.Cause) => Z1; readonly onSuccess: (a: A) => Z2; }): (self: Exit) => Z1 | Z2; /** * @since 2.0.0 * @category folding */ (self: Exit, options: { readonly onFailure: (cause: Cause.Cause) => Z1; readonly onSuccess: (a: A) => Z2; }): Z1 | Z2; }; /** * @since 2.0.0 * @category folding */ export declare const matchEffect: { /** * @since 2.0.0 * @category folding */ (options: { readonly onFailure: (cause: Cause.Cause) => Effect.Effect; readonly onSuccess: (a: A) => Effect.Effect; }): (self: Exit) => Effect.Effect; /** * @since 2.0.0 * @category folding */ (self: Exit, options: { readonly onFailure: (cause: Cause.Cause) => Effect.Effect; readonly onSuccess: (a: A) => Effect.Effect; }): Effect.Effect; }; /** * Constructs a new `Exit.Success` containing the specified value of type `A`. * * @since 2.0.0 * @category constructors */ export declare const succeed: (value: A) => Exit; declare const void_: Exit; export { /** * Represents an `Exit` which succeeds with `undefined`. * * @since 2.0.0 * @category constructors */ void_ as void }; /** * Sequentially zips the this result with the specified result or else returns * the failed `Cause`. * * @since 2.0.0 * @category zipping */ export declare const zip: { /** * Sequentially zips the this result with the specified result or else returns * the failed `Cause`. * * @since 2.0.0 * @category zipping */ (that: Exit): (self: Exit) => Exit<[A, A2], E2 | E>; /** * Sequentially zips the this result with the specified result or else returns * the failed `Cause`. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit): 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`. * * @since 2.0.0 * @category zipping */ export declare const zipLeft: { /** * Sequentially zips the this result with the specified result discarding the * second element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (that: Exit): (self: Exit) => Exit; /** * Sequentially zips the this result with the specified result discarding the * second element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit): Exit; }; /** * Sequentially zips the this result with the specified result discarding the * first element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ export declare const zipRight: { /** * Sequentially zips the this result with the specified result discarding the * first element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (that: Exit): (self: Exit) => Exit; /** * Sequentially zips the this result with the specified result discarding the * first element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit): Exit; }; /** * Parallelly zips the this result with the specified result or else returns * the failed `Cause`. * * @since 2.0.0 * @category zipping */ export declare const zipPar: { /** * Parallelly zips the this result with the specified result or else returns * the failed `Cause`. * * @since 2.0.0 * @category zipping */ (that: Exit): (self: Exit) => Exit<[A, A2], E2 | E>; /** * Parallelly zips the this result with the specified result or else returns * the failed `Cause`. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit): Exit<[A, A2], E | E2>; }; /** * Parallelly zips the this result with the specified result discarding the * second element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ export declare const zipParLeft: { /** * Parallelly zips the this result with the specified result discarding the * second element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (that: Exit): (self: Exit) => Exit; /** * Parallelly zips the this result with the specified result discarding the * second element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit): Exit; }; /** * Parallelly zips the this result with the specified result discarding the * first element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ export declare const zipParRight: { /** * Parallelly zips the this result with the specified result discarding the * first element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (that: Exit): (self: Exit) => Exit; /** * Parallelly zips the this result with the specified result discarding the * first element of the tuple or else returns the failed `Cause`. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit): Exit; }; /** * Zips this exit together with that exit using the specified combination * functions. * * @since 2.0.0 * @category zipping */ export declare const zipWith: { /** * Zips this exit together with that exit using the specified combination * functions. * * @since 2.0.0 * @category zipping */ (that: Exit, options: { readonly onSuccess: (a: A, b: B) => C; readonly onFailure: (cause: Cause.Cause, cause2: Cause.Cause) => Cause.Cause; }): (self: Exit) => Exit; /** * Zips this exit together with that exit using the specified combination * functions. * * @since 2.0.0 * @category zipping */ (self: Exit, that: Exit, options: { readonly onSuccess: (a: A, b: B) => C; readonly onFailure: (cause: Cause.Cause, cause2: Cause.Cause) => Cause.Cause; }): Exit; }; //# sourceMappingURL=Exit.d.ts.map