Package: effect
Module: Optic
Prism that focuses on the value inside Option.Some.
When to use
Use when you have an Option<A> and want to read/update the inner value only
when it is Some.
Details
getResult fails with an error message when the option is None.set(a) wraps a in Option.some(a).Example (Accessing Some value)
import { Optic, Option, Result } from "effect"
const _some = Optic.id<Option.Option<number>>().compose(Optic.some())
console.log(Result.isSuccess(_some.getResult(Option.some(42))))
// Output: true
console.log(Result.isFailure(_some.getResult(Option.none())))
// Output: true
console.log(_some.set(10))
// Output: { _tag: "Some", value: 10 }
See
none — focuses on None insteadPrism — the type this function returnsSignature
declare const some: <A>() => Prism<Option.Option<A>, A>
Since v4.0.0