<A, E>(self: Exit<A, E>): self is Success<A, E>Checks whether an Exit is a Success.
When to use
Use as a type guard to narrow Exit<A, E> to Success<A, E> and access the
value property.
Example (Narrowing to success)
import { Exit } from "effect"
const exit = Exit.succeed(42)
if (Exit.isSuccess(exit)) {
console.log(exit.value) // 42
}export const const isSuccess: <A, E>(
self: Exit<A, E>
) => self is Success<A, E>
Checks whether an Exit is a Success.
When to use
Use as a type guard to narrow Exit<A, E> to Success<A, E> and access the
value property.
Example (Narrowing to success)
import { Exit } from "effect"
const exit = Exit.succeed(42)
if (Exit.isSuccess(exit)) {
console.log(exit.value) // 42
}
isSuccess: <function (type parameter) A in <A, E>(self: Exit<A, E>): self is Success<A, E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): self is Success<A, 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, E>(self: Exit<A, E>): self is Success<A, E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): self is Success<A, E>E>) => self: Exit<A, E>self is interface Success<out A, out E = never>A successful Exit containing a value.
When to use
Use when working with the successful branch of an Exit after narrowing
with
isSuccess
. Access the value via the value property after
narrowing.
Example (Accessing the success value)
import { Exit } from "effect"
const success = Exit.succeed(42)
if (Exit.isSuccess(success)) {
console.log(success._tag) // "Success"
console.log(success.value) // 42
}
Success<function (type parameter) A in <A, E>(self: Exit<A, E>): self is Success<A, E>A, function (type parameter) E in <A, E>(self: Exit<A, E>): self is Success<A, E>E> = import effecteffect.const exitIsSuccess: <A, E>(
self: Exit.Exit<A, E>
) => self is Exit.Success<A, E>
exitIsSuccess