Package: effect
Module: Optic
Prism that focuses on the success value of a Result.
When to use
Use when you have a Result<A, E> and want to read/update A only when it
is a Success.
Details
getResult fails when the result is a Failure.set(a) produces Result.succeed(a).Example (Accessing success)
import { Optic, Result } from "effect"
const _ok = Optic.id<Result.Result<number, string>>().compose(Optic.success())
console.log(Result.isSuccess(_ok.getResult(Result.succeed(42))))
// Output: true
console.log(Result.isFailure(_ok.getResult(Result.fail("err"))))
// Output: true
See
failure — focuses on the failure sidePrism — the type this function returnsSignature
declare const success: <A, E>() => Prism<Result.Result<A, E>, A>
Since v4.0.0