Package: effect
Module: Option
Lifts a binary function to operate on two Option values.
When to use
Use when you need to reuse an existing binary function with two Option
values.
Details
Some → applies f and wraps in SomeNone → NoneExample (Lifting addition)
import { Option } from "effect"
const addOptions = Option.lift2((a: number, b: number) => a + b)
console.log(addOptions(Option.some(2), Option.some(3)))
// Output: { _id: 'Option', _tag: 'Some', value: 5 }
console.log(addOptions(Option.some(2), Option.none()))
// Output: { _id: 'Option', _tag: 'None' }
See
zipWith for a non-lifted variantSignature
declare const lift2: <A, B, C>(f: (a: A, b: B) => C) => { (that: Option<B>): (self: Option<A>) => Option<C>; (self: Option<A>, that: Option<B>): Option<C>; }
Since v2.0.0