This package contains some common functions for processing (functional) option-values.
Please see option.sats and option.dats for the SATS file and DATS file in ATSLIB where the functions in this package are declared and implemented, respectively.
The full name for the option-type constructor option is option_t0ype_bool_type, which is given to the datatype declared as follows:
datatype // t@ype+: covariant option_t0ype_bool_type (a:t@ype+, bool) = Some (a, true) of a | None (a, false) // end of [datatype]
fun{ a1,a2:t@ype } option_zip {b1,b2:bool} ( opt1: option (a1, b1), opt2: option (a2, b2) ) : option (@(a1, a2), b1*b2) = case+ opt1 of | Some (x1) => ( case+ opt2 of | Some (x2) => Some @(x1, x2) | None () => None () ) | None () => None () // end of [option_zip]
typedef Option (a:t0p) = [b:bool] option(a, b)
exception NotSomeExn of ()
castfn option_cast {a:t0p}{b:bool} ( opt: option(INV(a), b) ) :<> option(a, b) // end-of-fun
castfn option_vt2t {a:t0p}{b:bool} ( opt: option_vt(INV(a), b) ) :<> option(a, b) // end-of-fun
castfn option_of_option_vt {a:t0p}{b:bool} ( opt: option_vt(INV(a), b) ) :<> option(a, b) // end-of-fun
fun{a:t0p}
option_some
(x0: a):<> option(a, true)
fun{a:t0p}
option_none
((*void*)):<> option(a, false)
fun{}
option_is_some
{a:t0p}{b:bool}
(opt: option(a, b)):<> bool(b)
fun{}
option_is_none
{a:t0p}{b:bool}
(opt: option(a, b)):<> bool(~b)
fun{a:t0p}
option_unsome
(option(INV(a), true)):<> (a)
fun{a:t0p}
option_unsome_exn
(opt: Option(INV(a))):<!exn> (a)
overload fprint with fprint_option of 0
This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. |
|