<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>
}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
- Both
Some→ appliesfand wraps inSome - Either
None→None
Example (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' }export const 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>
}
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
- Both
Some → applies f and wraps in Some
- Either
None → None
Example (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' }
lift2 = <function (type parameter) A in <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>;
}
A, function (type parameter) B in <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>;
}
B, function (type parameter) C in <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>;
}
C>(f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <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>;
}
A, b: Bb: function (type parameter) B in <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>;
}
B) => function (type parameter) C in <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>;
}
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 <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>;
}
B>): (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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): 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 <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>;
}
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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): 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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): Option<C>;
}
B>): 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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): Option<C>;
}
C>
} => import dualdual(2, (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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): 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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): Option<C>;
}
B>): 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>(f: (a: A, b: B) => C): {
(that: Option<B>): (self: Option<A>) => Option<C>;
(self: Option<A>, that: Option<B>): Option<C>;
}
C> => 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>
}
zipWith(self: Option<A>self, that: Option<B>that, f: (a: A, b: B) => Cf))