module Stdlib.Data.Maybe.Base;
--- Represents an optional value that may or may not be present. Provides a way
--- to handle null or missing values in a type-safe manner.
type Maybe A :=
| nothing
| just A;
--- Extracts the value from a ;Maybe; if present, else returns the given value.
fromMaybe {A} (a : A) : Maybe A → A
| nothing := a
| (just a) := a;
--- Applies a function to the value from a ;Maybe; if present, else returns the
--- given value.
maybe {A B} (b : B) (f : A → B) : Maybe A → B
| nothing := b
| (just a) := f a;
Last modified on 2023-10-06 13:21 UTC