<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>Transforms the success value of an Exit using the given function.
When to use
Use to apply a transformation to the value inside a successful Exit
Details
Failures pass through unchanged.
Allocates a new Exit if successful.
Example (Mapping over a success)
import { Exit } from "effect"
const exit = Exit.succeed(21)
const doubled = Exit.map(exit, (x) => x * 2)
console.log(Exit.isSuccess(doubled) && doubled.value) // 42export const 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>
}
Transforms the success value of an Exit using the given function.
When to use
Use to apply a transformation to the value inside a successful Exit
Details
Failures pass through unchanged.
Allocates a new Exit if successful.
Example (Mapping over a success)
import { Exit } from "effect"
const exit = Exit.succeed(21)
const doubled = Exit.map(exit, (x) => x * 2)
console.log(Exit.isSuccess(doubled) && doubled.value) // 42
map: {
<function (type parameter) A in <A, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>A, function (type parameter) B in <A, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>B>(f: (a: A) => Bf: (a: Aa: function (type parameter) A in <A, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>A) => function (type parameter) B in <A, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>B): <function (type parameter) E in <E>(self: Exit<A, E>): Exit<B, E>E>(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, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>A, function (type parameter) E in <E>(self: Exit<A, E>): Exit<B, E>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) B in <A, B>(f: (a: A) => B): <E>(self: Exit<A, E>) => Exit<B, E>B, function (type parameter) E in <E>(self: Exit<A, E>): Exit<B, E>E>
<function (type parameter) A in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>A, function (type parameter) E in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>E, function (type parameter) B in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>B>(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, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>A, function (type parameter) E in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>E>, f: (a: A) => Bf: (a: Aa: function (type parameter) A in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>A) => function (type parameter) B in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>B): 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) B in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>B, function (type parameter) E in <A, E, B>(self: Exit<A, E>, f: (a: A) => B): Exit<B, E>E>
} = import effecteffect.const exitMap: {
<A, B>(f: (a: A) => B): <E>(
self: Exit.Exit<A, E>
) => Exit.Exit<B, E>
<A, E, B>(
self: Exit.Exit<A, E>,
f: (a: A) => B
): Exit.Exit<B, E>
}
exitMap