Module Data.Or_null

type (('a : value_or_null), 'k) t
val wrap : 'a 'k. access:'k Access.t -> 'a -> ('a, 'k) t @@ portable

wrap ~access v returns a pointer to the value v, which lives in the capsule 'k. 'k is always the current capsule.

val unwrap : 'a 'k. access:'k Access.t -> ('a, 'k) t -> 'a @@ portable

unwrap ~access t returns the value of t, which lives in the capsule 'k. 'k is always the current capsule.

val create : 'a 'k. (unit -> 'a) @ local once portable -> ('a, 'k) t @@ portable

create f runs f within the capsule 'k and returns a pointer to the result of f.

val project : 'a 'k. ('a, 'k) t -> 'a @ contended @@ portable

project t returns the value of t. The result is within 'k, so is marked contended. The value is required to always be portable, so unlike extract, project does not require permission to access 'k. This is safe because all accesses to the value happen only after it's marked contended.