Module Option

Option<a> is either .some a or .none!.

  • .some a carries a value.
  • .none! means no value is available.
type Option<a> = either {
  .none!,
  .some a,
}

An optional value, either .some a or .none!.

dec Option.Filter : <a: box>[Option<a>] [box [a] Bool] Option<a>

Keeps the contained value only if it satisfies the predicate.

dec Option.FlatMap : <a>[Option<a>] <b>[box [a] Option<b>] Option<b>

Transforms the contained value with a computation that may return no value.

dec Option.Map : <a>[Option<a>] <b>[box [a] b] Option<b>

Transforms the contained value, if present.

dec Option.ToList : <a>[Option<a>] List<a>

Converts .some value to a singleton list and .none! to an empty list.

dec Option.ToResult : <a>[Option<a>] <e: box>[e] Try<e, a>

Converts .some value to .ok value and .none! to the provided error.