Package: effect
Module: Option
Wraps the first element of an Iterable in a Some, or returns None if
the iterable is empty.
When to use
Use when you need to safely extract the head of a collection, including generators or lazy iterables.
Details
None for empty iterablesExample (Getting the first element)
import { Option } from "effect"
console.log(Option.fromIterable([1, 2, 3]))
// Output: { _id: 'Option', _tag: 'Some', value: 1 }
console.log(Option.fromIterable([]))
// Output: { _id: 'Option', _tag: 'None' }
See
toArray for the inverse directionSignature
declare const fromIterable: <A>(collection: Iterable<A>) => Option<A>
Since v2.0.0