<E, E2, A, 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>Transforms both the success value and typed error of an Exit.
When to use
Use when you need to remap both channels in one step.
Details
onSuccess transforms the value if the Exit is a Success. onFailure
transforms the typed error if the Exit is a Failure with a Fail reason.
Allocates a new Exit.
Gotchas
If the Cause contains only defects or interruptions, the failure passes through unchanged.
Example (Mapping both channels)
import { Data, Exit } from "effect"
class ExitError extends Data.TaggedError("ExitError")<{ readonly input: string }> {}
const exit = Exit.succeed(42)
const mapped = Exit.mapBoth(exit, {
onSuccess: (x) => String(x),
onFailure: (e: string) => new ExitError({ input: e })
})
console.log(Exit.isSuccess(mapped) && mapped.value) // "42"export const const mapBoth: {
<E, E2, A, 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>
}
Transforms both the success value and typed error of an Exit.
When to use
Use when you need to remap both channels in one step.
Details
onSuccess transforms the value if the Exit is a Success. onFailure
transforms the typed error if the Exit is a Failure with a Fail reason.
Allocates a new Exit.
Gotchas
If the Cause contains only defects or interruptions, the failure passes
through unchanged.
Example (Mapping both channels)
import { Data, Exit } from "effect"
class ExitError extends Data.TaggedError("ExitError")<{ readonly input: string }> {}
const exit = Exit.succeed(42)
const mapped = Exit.mapBoth(exit, {
onSuccess: (x) => String(x),
onFailure: (e: string) => new ExitError({ input: e })
})
console.log(Exit.isSuccess(mapped) && mapped.value) // "42"
mapBoth: {
<function (type parameter) E in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
E, function (type parameter) E2 in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
E2, function (type parameter) A in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
A, function (type parameter) A2 in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
A2>(
options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}
options: { readonly onFailure: (e: E) => E2onFailure: (e: Ee: function (type parameter) E in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
E) => function (type parameter) E2 in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
E2; readonly onSuccess: (a: A) => A2onSuccess: (a: Aa: function (type parameter) A in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
A) => function (type parameter) A2 in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
A2 }
): (self: Exit<A, E>self: type Exit<A, E = never> = Success<A, E> | Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<function (type parameter) A in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
A, function (type parameter) E in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
E>) => type Exit<A, E = never> = Success<A, E> | Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<function (type parameter) A2 in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
A2, function (type parameter) E2 in <E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): (self: Exit<A, E>) => Exit<A2, E2>
E2>
<function (type parameter) A in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
A, function (type parameter) E in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
E, function (type parameter) E2 in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
E2, function (type parameter) A2 in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
A2>(
self: Exit<A, E>self: type Exit<A, E = never> = Success<A, E> | Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<function (type parameter) A in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
A, function (type parameter) E in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
E>,
options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}
options: { readonly onFailure: (e: E) => E2onFailure: (e: Ee: function (type parameter) E in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
E) => function (type parameter) E2 in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
E2; readonly onSuccess: (a: A) => A2onSuccess: (a: Aa: function (type parameter) A in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
A) => function (type parameter) A2 in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
A2 }
): type Exit<A, E = never> = Success<A, E> | Failure<A, E>Represents the result of an Effect computation.
When to use
Use when you need to synchronously inspect whether an Effect computation
succeeded or failed.
Details
An Exit<A, E> is either Success<A, E> containing a value of type A, or
Failure<A, E> containing a Cause<E> describing why the computation
failed.
Since Exit is also an Effect, you can yield it inside Effect.gen.
Example (Pattern matching on an Exit)
import { Exit } from "effect"
const success: Exit.Exit<number> = Exit.succeed(42)
const failure: Exit.Exit<number, string> = Exit.fail("error")
const result = Exit.match(success, {
onSuccess: (value) => `Got value: ${value}`,
onFailure: (cause) => `Got error: ${cause}`
})
Namespace containing helper types shared by Exit values.
When to use
Use to reference helper types that describe the shared structure of Exit
values.
Exit<function (type parameter) A2 in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
A2, function (type parameter) E2 in <A, E, E2, A2>(self: Exit<A, E>, options: {
readonly onFailure: (e: E) => E2;
readonly onSuccess: (a: A) => A2;
}): Exit<A2, E2>
E2>
} = import effecteffect.const exitMapBoth: {
<E, E2, A, A2>(options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}): (self: Exit.Exit<A, E>) => Exit.Exit<A2, E2>
<A, E, E2, A2>(
self: Exit.Exit<A, E>,
options: {
readonly onFailure: (e: E) => E2
readonly onSuccess: (a: A) => A2
}
): Exit.Exit<A2, E2>
}
exitMapBoth