<B>(that: Option<B>): <_>(self: Option<_>) => Option<B>
<X, B>(self: Option<X>, that: Option<B>): Option<B>Sequences two Options, keeping the value from the second if both are Some.
When to use
Use when you need two Option values to both be Some, then keep only the
second value.
Details
- Both
Some→ returnsthat - Either
None→ returnsNone
Example (Keeping the second value)
import { Option } from "effect"
console.log(Option.zipRight(Option.some(1), Option.some("hello")))
// Output: { _id: 'Option', _tag: 'Some', value: 'hello' }
console.log(Option.zipRight(Option.none(), Option.some("hello")))
// Output: { _id: 'Option', _tag: 'None' }export const const zipRight: {
<B>(that: Option<B>): <_>(
self: Option<_>
) => Option<B>
<X, B>(
self: Option<X>,
that: Option<B>
): Option<B>
}
Sequences two Options, keeping the value from the second if both are Some.
When to use
Use when you need two Option values to both be Some, then keep only the
second value.
Details
- Both
Some → returns that
- Either
None → returns None
Example (Keeping the second value)
import { Option } from "effect"
console.log(Option.zipRight(Option.some(1), Option.some("hello")))
// Output: { _id: 'Option', _tag: 'Some', value: 'hello' }
console.log(Option.zipRight(Option.none(), Option.some("hello")))
// Output: { _id: 'Option', _tag: 'None' }
zipRight: {
<function (type parameter) B in <B>(that: Option<B>): <_>(self: Option<_>) => Option<B>B>(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>(that: Option<B>): <_>(self: Option<_>) => Option<B>B>): <function (type parameter) _ in <_>(self: Option<_>): Option<B>_>(self: Option<_>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) _ in <_>(self: Option<_>): Option<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) B in <B>(that: Option<B>): <_>(self: Option<_>) => Option<B>B>
<function (type parameter) X in <X, B>(self: Option<X>, that: Option<B>): Option<B>X, function (type parameter) B in <X, B>(self: Option<X>, that: Option<B>): Option<B>B>(self: Option<X>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) X in <X, B>(self: Option<X>, that: Option<B>): Option<B>X>, 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 <X, B>(self: Option<X>, that: Option<B>): Option<B>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) B in <X, B>(self: Option<X>, that: Option<B>): Option<B>B>
} = import dualdual(2, <function (type parameter) X in <X, B>(self: Option<X>, that: Option<B>): Option<B>X, function (type parameter) B in <X, B>(self: Option<X>, that: Option<B>): Option<B>B>(self: Option<X>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) X in <X, B>(self: Option<X>, that: Option<B>): Option<B>X>, 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 <X, B>(self: Option<X>, that: Option<B>): Option<B>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) B in <X, B>(self: Option<X>, that: Option<B>): Option<B>B> => const flatMap: {
<A, B>(f: (a: A) => Option<B>): (
self: Option<A>
) => Option<B>
<A, B>(
self: Option<A>,
f: (a: A) => Option<B>
): Option<B>
}
flatMap(self: Option<X>self, () => that: Option<B>that))