module MetaVar: sig
.. end
type
id = ID.t
type 'a
t = private {
|
id : id ; |
|
mutable deref : 'a option ; |
}
Pointer to another type
val make : name:string -> 'a t
New reference, with a fresh ID
val id : 'a t -> id
Id of the variable
val equal : 'a t -> 'a t -> bool
Name equality (ignores the deref
field)
val deref : 'a t -> 'a option
Access the content
val can_bind : 'a t -> bool
can_bind t
returns true
iff t.deref = None
val bound : 'a t -> bool
bound v
is not (can_bind v)
val bind : var:'a t -> 'a -> unit
bind ~var t
binds ref
to t
. From now on,
the holder of ref
should behave like t
in all aspects.
Raises Invalid_argument
if var
is already bound
val rebind : var:'a t -> 'a -> unit
re-bind an already bound reference (for instance, for path compression).
Raises Invalid_argument
if the ref is not bound
val update : f:('a -> 'b) -> 'a t -> 'b t
Update the linked content, if any
val print : Format.formatter -> 'a t -> unit
val to_string : 'a t -> string