<A>(value: A): Option<A>Wraps the given value into an Option to represent its presence.
When to use
Use to wrap a known present value as Option
- Returning a successful result from a partial function
Details
- Always returns
Some<A> - Does not filter
nullorundefined; use fromNullishOr for that
Example (Wrapping a value)
import { Option } from "effect"
// ┌─── Option<number>
// ▼
const value = Option.some(1)
console.log(value)
// Output: { _id: 'Option', _tag: 'Some', value: 1 }Source effect/Option.ts:2921 lines
export const const some: <A>(value: A) => Option<A>Wraps the given value into an Option to represent its presence.
When to use
Use to wrap a known present value as Option
- Returning a successful result from a partial function
Details
- Always returns
Some<A>
- Does not filter
null or undefined; use
fromNullishOr
for that
Example (Wrapping a value)
import { Option } from "effect"
// ┌─── Option<number>
// ▼
const value = Option.some(1)
console.log(value)
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
some: <function (type parameter) A in <A>(value: A): Option<A>A>(value: Avalue: function (type parameter) A in <A>(value: 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>(value: A): Option<A>A> = import optionoption.const some: <A>(
value: A
) => Option.Option<A>
someReferenced by 148 symbols
Array.dedupeAdjacentWithArray.findFirstIndexArray.findFirstWithIndexArray.findLastArray.findLastIndexArray.getArray.initArray.insertAtArray.lastArray.modifyArray.tailBigDecimal.divideBigDecimal.fromNumberBigDecimal.fromStringBigDecimal.remainderBigInt.divideBigInt.fromNumberBigInt.fromStringBigInt.sqrtBigInt.toNumberBrand.nominalChannel.acquireUseReleaseChannel.fromIteratorArrayChannel.splitLinesChunk.ChunkChunk.getChunk.tailConfig.optionContext.ReferenceContext.getOptionDuration.divideFilter.toOptionGraph.astarGraph.bellmanFordGraph.dijkstraGraph.directedGraph.findEdgeGraph.findNodeGraph.getNodeGraph.isAcyclic+108 more