<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>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
- Both
Some→ appliesf(a, b)and wraps inSome - Either
None→None
Example (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 } }export const 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>
}
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
- Both
Some → applies f(a, b) and wraps in Some
- Either
None → None
Example (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 } }
zipWith: {
<function (type parameter) B in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>B, function (type parameter) A in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>A, function (type parameter) C in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>C>(that: Option<B>that: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) B in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>B>, f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>A, b: Bb: function (type parameter) B in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>B) => function (type parameter) C in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>C): (self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>A>) => type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) C in <B, A, C>(that: Option<B>, f: (a: A, b: B) => C): (self: Option<A>) => Option<C>C>
<function (type parameter) A in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>A, function (type parameter) B in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>B, function (type parameter) C in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>C>(self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>A>, that: Option<B>that: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) B in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>B>, f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>A, b: Bb: function (type parameter) B in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>B) => function (type parameter) C in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>C): type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) C in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>C>
} = import dualdual(
3,
<function (type parameter) A in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>A, function (type parameter) B in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>B, function (type parameter) C in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>C>(self: Option<A>self: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) A in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>A>, that: Option<B>that: type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) B in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>B>, f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>A, b: Bb: function (type parameter) B in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>B) => function (type parameter) C in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>C): type Option<A> = None<A> | Some<A>The Option data type represents optional values. An Option<A> is either
Some<A>, containing a value of type A, or None, representing absence.
When to use
Use to represent initial values that may not yet exist
- Returning from partial functions (not defined for all inputs)
- Managing optional fields in data structures
Namespace containing utility types for Option.
When to use
Use to access type-level helpers associated with Option.
Option<function (type parameter) C in <A, B, C>(self: Option<A>, that: Option<B>, f: (a: A, b: B) => C): Option<C>C> =>
const map: {
<A, B>(f: (a: A) => B): (
self: Option<A>
) => Option<B>
<A, B>(
self: Option<A>,
f: (a: A) => B
): Option<B>
}
map(const product: <A, B>(
self: Option<A>,
that: Option<B>
) => Option<[A, B]>
Combines two Options into a Some containing a tuple [A, B] if both
are Some.
When to use
Use when you need to require two Option values to both be Some and keep
both values as a tuple.
Details
- Both
Some → Some([a, b])
- Either
None → None
Example (Pairing two Options)
import { Option } from "effect"
console.log(Option.product(Option.some("hello"), Option.some(42)))
// Output: { _id: 'Option', _tag: 'Some', value: ['hello', 42] }
console.log(Option.product(Option.none(), Option.some(42)))
// Output: { _id: 'Option', _tag: 'None' }
product(self: Option<A>self, that: Option<B>that), ([a: Aa, b: Bb]) => f: (a: A, b: B) => Cf(a: Aa, b: Bb))
)