This package contains some common functions for processing linear option-values.
Please see option_vt.sats and option_vt.dats for the SATS file and DATS file in ATSLIB where the functions in this package are declared and implemented, respectively.
stadef option_vt = option_vt0ype_bool_vtype
The full name for the linear option-type constructor option_vt is option_viewt0ype_bool_viewtype, which is given to the linear datatype (dataviewtype) declared as follows:
dataviewtype // viewt@ype+: covariant option_viewt0ype_bool_viewtype (a:viewt@ype+, bool) = Some_vt (a, true) of a | None_vt (a, false) // end of [option_viewt0ype_bool_viewtype]
fun{ a1,a2:t0p } option_vt_zip {b1,b2:bool} ( opt1: option_vt (a1, b1), opt2: option_vt (a2, b2) ) : option_vt (@(a1, a2), b1*b2) = case+ opt1 of | ~Some_vt (x1) => ( case+ opt2 of | ~Some_vt (x2) => Some_vt @(x1, x2) | ~None_vt () => None_vt () ) | ~None_vt () => let val () = option_vt_free (opt2) in None_vt () end // end of [None_vt] // end of [option_vt_zip]
vtypedef Option_vt (a:vt0p) = [b:bool] option_vt (a, b)
fun{a:vt0p}
option_vt_some (x: a):<!wrt> option_vt (a, true)
fun{a:vt0p}
option_vt_none ((*void*)):<!wrt> option_vt (a, false)
fun{}
option_vt_is_some
{a:vt0p}{b:bool}
(opt: !option_vt(INV(a), b)):<> bool(b)
fun{}
option_vt_is_none
{a:vt0p}{b:bool}
(opt: !option_vt(INV(a), b)):<> bool(~b)
fun
{a:vt0p}
option_vt_unsome
(opt: option_vt(INV(a), true)):<!wrt> (a)
fun
{a:vt0p}
option_vt_unnone
(opt: option_vt(INV(a), false)):<!wrt> void
fun{ a:vt0p } option_vt_make_opt {b:bool} ( b: bool(b) , x: &opt (INV(a), b) >> a? ) :<!wrt> option_vt(a, b) // end-of-fun
fun{a:t0p}
option_vt_free
(opt: Option_vt(INV(a))):<!wrt> void
overload fprint with fprint_option_vt
This page is created with ATS by Hongwei Xi and also maintained by Hongwei Xi. |