The Option structure defines the option type, used for handling
partial functions and optional values, and provides a collection of
common combinators.
The type, the Option exception, and the functions getOpt, valOf, and
isSome are available in the top-level environment.
structure Option : OPTION
signature OPTION =
sigdatatype 'a option = NONE | SOME of 'a
exception Option
valgetOpt : 'a option * 'a -> 'a
valisSome : 'a option -> bool
valvalOf : 'a option -> 'a
valfilter : ('a -> bool) -> 'a -> 'a option
valjoin : 'a option option -> 'a option
valapp : ('a -> unit) -> 'a option -> unit
valmap : ('a -> 'b) -> 'a option -> 'b option
valmapPartial : ('a -> 'b option) -> 'a option -> 'b option
valcompose : ('a -> 'b) * ('c -> 'a option) -> 'c -> 'b option
valcomposePartial : ('a -> 'b option) * ('c -> 'a option) -> 'c -> 'b option
end
[type 'a option]
The type option provides a distinction between some
value and no value, and is often used for representing the result of
partially defined functions. It can be viewed as a typed version of
the C convention of returning a NULL pointer to indicate no value.
returns NONE if g(a) is NONE; otherwise, if g(a) is
SOME(v), it returns SOME(f v). Thus, the compose function composes f
with the partial function g to produce another partial function. The
expression compose (f, g) is equivalent to (map f) o g.
returns NONE if g(a) is NONE; otherwise, if
g(a) is SOME(v), it returns f(v). Thus, the composePartial function
composes the two partial functions f and g to produce another partial
function. The expression composePartial (f, g) is equivalent to
(mapPartial f) o g.