Options
Module options
import options
| Module | options |
| Source | options/module-docs.zirr, options/options.zirr |
Helpers for
Option, and for anything shaped like one.
prelude.Option is the type; options is what you use it with.
Every function accepts a bare value as well as a Some or None, because from normalizes first: an existing option passes through, and anything else is lifted into Some. That means these helpers can be applied to a value whose origin you do not control, without checking whether it was already optional.
Contents
Functions
flatMap
`options/options.zirr:37`
fn flatMap(o, transform: fn(Any) -> @AnyOption) -> Option
Returns transform(o’s value) normalized to Option, or None unchanged. Use this instead of map when transform can itself be absent.
from
`options/options.zirr:4`
fn from(o) -> Option
Normalizes o to Option: None stays None, an existing Some stays as it is, and any other value is lifted into Some(o).
isNone
`options/options.zirr:21`
fn isNone(o) -> Bool
Returns whether o is absent.
isSome
`options/options.zirr:16`
fn isSome(o) -> Bool
Returns whether o is present.
map
`options/options.zirr:26`
fn map(o, transform: fn(Any) -> Any) -> Option
Returns a Some with transform applied to o’s value, or None unchanged.
or
`options/options.zirr:48`
fn or(o, default: Any) -> Any
Returns o’s value, or default if o is absent.