Module Base.Ref
Module for the type ref
, mutable indirection cells r
containing a value of type 'a
, accessed with !r
and set by r := a
.
type 'a t
= 'a Base__.Import.Caml.ref
=
{
mutable contents : 'a;
}
val replace : 'a t -> ('a -> 'a) -> unit
replace t f
ist := f !t
val set_temporarily : 'a t -> 'a -> f:(unit -> 'b) -> 'b
set_temporarily t a ~f
setst
toa
, callsf ()
, and then restorest
to its value prior toset_temporarily
being called, whetherf
returns or raises.