<B>(b: B): <X>(self: Option<X>) => Option<B>
<X, B>(self: Option<X>, b: B): Option<B>Replaces the value inside a Some with a constant, leaving None unchanged.
When to use
Use when you need to replace a present Option value while preserving
whether it was Some or None.
Example (Replacing a value)
import { Option } from "effect"
console.log(Option.as(Option.some(42), "new value"))
// Output: { _id: 'Option', _tag: 'Some', value: 'new value' }
console.log(Option.as(Option.none(), "new value"))
// Output: { _id: 'Option', _tag: 'None' }export const const as: {
<B>(b: B): <X>(self: Option<X>) => Option<B>
<X, B>(self: Option<X>, b: B): Option<B>
}
Replaces the value inside a Some with a constant, leaving None unchanged.
When to use
Use when you need to replace a present Option value while preserving
whether it was Some or None.
Example (Replacing a value)
import { Option } from "effect"
console.log(Option.as(Option.some(42), "new value"))
// Output: { _id: 'Option', _tag: 'Some', value: 'new value' }
console.log(Option.as(Option.none(), "new value"))
// Output: { _id: 'Option', _tag: 'None' }
as: {
<function (type parameter) B in <B>(b: B): <X>(self: Option<X>) => Option<B>B>(b: Bb: function (type parameter) B in <B>(b: B): <X>(self: Option<X>) => Option<B>B): <function (type parameter) X in <X>(self: Option<X>): Option<B>X>(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>(self: Option<X>): Option<B>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) B in <B>(b: B): <X>(self: Option<X>) => Option<B>B>
<function (type parameter) X in <X, B>(self: Option<X>, b: B): Option<B>X, function (type parameter) B in <X, B>(self: Option<X>, b: 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>, b: B): Option<B>X>, b: Bb: function (type parameter) B in <X, B>(self: Option<X>, b: 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>, b: B): Option<B>B>
} = import dualdual(2, <function (type parameter) X in <X, B>(self: Option<X>, b: B): Option<B>X, function (type parameter) B in <X, B>(self: Option<X>, b: 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>, b: B): Option<B>X>, b: Bb: function (type parameter) B in <X, B>(self: Option<X>, b: 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>, b: B): Option<B>B> => 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(self: Option<X>self, () => b: Bb))