once.ml
spotlib
1 2 3 4 5 6 7 8 9 10 11 12 type 'a t = 'a option ref let create () = ref None exception Already_initialized let set x v = match x with | {contents = Some _} -> raise Already_initialized | r -> r := Some v let get x = !x
1 2 3 4 5 6 7 8 9 10 11 12
type 'a t = 'a option ref let create () = ref None exception Already_initialized let set x v = match x with | {contents = Some _} -> raise Already_initialized | r -> r := Some v let get x = !x