package um-abt

  1. Overview
  2. Docs

Module Abt.VarSource

Variables, named by strings, which can be bound to a Var.Binding or left free.

Sourcemodule Binding : sig ... end

A binding is an immutable reference, to which a bound can refer.

Sourcetype t = private
  1. | Free of string
  2. | Bound of Binding.t
    (*

    A varibale of type t is either free or bound.

    *)
Sourceval compare : t -> t -> int

Bound variables are equal if they are have the same binding, free variables are greater than bound variables, and variables are otherwise compared lexigraphically by name.

Specifically,

compare a b is 0 iff

  • is_free a && is_free b and name a = name b
  • is_bound a && is_bound b and both a and b are bound to the same binding by way of bind.

compare a b is String.compare (name a) (name b) if is_free a && is_free b or is_bound a && is_bound b.

compare a b is -1 if is_bound a and is_free b or 1 if is_free a and is_bound b

Sourceval equal : t -> t -> bool

equal a b is true iff

  • is_free a && is_free b and name a = name b
  • is_bound a && is_bound b and both a and b are bound to the same binding by way of bind.
Sourceval is_free : t -> bool
Sourceval is_bound : t -> bool
Sourceval v : string -> t
Sourceval to_string : t -> string
Sourceval name : t -> string

name v is to_string v

Sourceval bind : t -> Binding.t -> t option

bind v bnd is Some var when is_free v and name v = Binding.name bnd, where var is a new variable with the same name but bound to bnd. Otherwise, it is None.

See equal.

Sourceval is_bound_to : t -> Binding.t -> bool

is_bound_to v bnd is true if v is bound to bnd, via bind

Sourceval of_binding : Binding.t -> t

of_binding bnd is a variable bound to bnd

Sourceval to_binding : t -> Binding.t option

to_binding v is Some bnd iff v is bound to bnd via bind. Otherwise it is None.

Sourcemodule Set : Set.S with type elt = t
Sourcemodule Map : Map.S with type key = t