(u: unknown): u is Exit<unknown, unknown>Checks whether an unknown value is an Exit.
When to use
Use to validate unknown values at system boundaries and narrow them to
Exit<unknown, unknown>.
Details
Does not inspect the contents of the Exit. Returns true for both Success
and Failure exits.
Example (Checking if a value is an Exit)
import { Exit } from "effect"
console.log(Exit.isExit(Exit.succeed(42))) // true
console.log(Exit.isExit(Exit.fail("err"))) // true
console.log(Exit.isExit("not an exit")) // falseexport const const isExit: (
u: unknown
) => u is Exit<unknown, unknown>
Checks whether an unknown value is an Exit.
When to use
Use to validate unknown values at system boundaries and narrow them to
Exit<unknown, unknown>.
Details
Does not inspect the contents of the Exit. Returns true for both Success
and Failure exits.
Example (Checking if a value is an Exit)
import { Exit } from "effect"
console.log(Exit.isExit(Exit.succeed(42))) // true
console.log(Exit.isExit(Exit.fail("err"))) // true
console.log(Exit.isExit("not an exit")) // false
isExit: (u: unknownu: unknown) => u: unknownu is 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<unknown, unknown> = import corecore.const isExit: (
u: unknown
) => u is Exit.Exit<unknown, unknown>
isExit