Package: effect
Module: Option
Combines two Options using a provided function.
When to use
Use when you need to combine two present Option values into a computed
result.
Details
Some → applies f(a, b) and wraps in SomeNone → NoneExample (Combining with a function)
import { Option } from "effect"
const person = Option.zipWith(
Option.some("John"),
Option.some(25),
(name, age) => ({ name: name.toUpperCase(), age })
)
console.log(person)
// Output:
// { _id: 'Option', _tag: 'Some', value: { name: 'JOHN', age: 25 } }
See
product to combine into a tuple insteadlift2 to lift a binary functionSignature
declare const zipWith: { <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>; <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>; }
Since v2.0.0