Hyperlinkv0.8.0-beta.28

Option

Option.someconsteffect/Option.ts:292
<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 }
constructorsfromNullishOrnone
Source effect/Option.ts:2921 lines
export const some: <A>(value: A) => Option<A> = option.some
Referenced by 148 symbols