Skip to main content
Version: Next

option

The module of optional values

value: <a>(default: a, opt: option<a>) => a

The call Option.value(d, opt) is v if opt is ["Some" as "Some", v], and d otherwise.

value_with_error: <err, a>(error: err, opt: option<a>) => a

The call Option.value_with_error(err, opt) terminates with the error err if, and only if, opt is ["None" as "None"]; otherwise it is ["Some" as "Some", v] and v is returned.

map: <a, b>(f: (_: a) => b, opt: option<a>) => option<b>

The call Option.map(f, opt) is ["None" as "None"] if opt is ["None" as "None"], and ["Some" as "Some", f(v)] if opt is ["Some" as "Some", v].

is_none: <a>(_: option<a>) => bool

The call Option.is_none(opt) is true if, and only if, opt is ["None" as "None"].

is_some: <a>(_: option<a>) => bool

The call Option.is_some(opt) is false if, and only if, opt is ["None" as "None"].