blob: c13386e12502f77caf413765d151ac1188a40339 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#define ATS_DYNLOADFLAG 0
staload "lib/SATS/valid.sats"
assume valid(a:viewt@ype,b:bool) = (a,bool b)
implement{a} create_valid(value) = (value,true)
// Create unvalid value by casting null pointer to type.
implement{a} create_unvalid() = let
staload UN = "prelude/SATS/unsafe.sats"
in
($UN.ptr0_get<a>(the_null_ptr),false) //UNSAFE:
end
implement{a} unwrap_valid(v) = v.0
implement{a} is_valid(v) = v.1
|