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