<A>(self: Option<A>): self is Some<A>Checks whether an Option contains a value (Some).
When to use
Use when you need to branch on a present Option before accessing .value.
Details
- Acts as a type guard, narrowing to
Some<A>
Example (Checking for Some)
import { Option } from "effect"
console.log(Option.isSome(Option.some(1)))
// Output: true
console.log(Option.isSome(Option.none()))
// Output: falseguardsisNone
Source effect/Option.ts:3881 lines
export const const isSome: <A>(
self: Option<A>
) => self is Some<A>
Checks whether an Option contains a value (Some).
When to use
Use when you need to branch on a present Option before accessing .value.
Details
- Acts as a type guard, narrowing to
Some<A>
Example (Checking for Some)
import { Option } from "effect"
console.log(Option.isSome(Option.some(1)))
// Output: true
console.log(Option.isSome(Option.none()))
// Output: false
isSome: <function (type parameter) A in <A>(self: Option<A>): self is Some<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>): self is Some<A>A>) => self: Option<A>self is interface Some<out A>Some<function (type parameter) A in <A>(self: Option<A>): self is Some<A>A> = import optionoption.const isSome: <A>(
fa: Option.Option<A>
) => fa is Option.Some<A>
isSomeReferenced by 50 symbols
Array.findFirstWithIndexArray.findLastArray.getSomesCache.getChannel.acquireUseReleaseChunk.ChunkChunk.compactFiberMap.setUnsafeGraph.astarGraph.bfsGraph.dfsPostOrderGraph.filterMapEdgesGraph.filterMapNodesGraph.isAcyclicGraph.topoIterable.findFirstIterable.findLastIterable.getSomesMutableHashMap.hasMutableHashMap.modifyAtOptic.someOption.firstSomeOfOption.getOrThrowWithOption.makeOrderOption.productOption.reduceCompactOption.toRefinementRecord.getSomesSchema.OptionSchema.RedactedSchema.RedactedFromValueSchema.extendToSchemaGetter.withDefaultScopedCache.getScopedCache.refreshScopedCache.setStream.groupByStream.groupByKeyStream.withExecutionPlanTxDeferred.done+10 more