module Variant:sig
..end
type 'v
cons
'v cons
is the set of constructors of variant 'v
, it
is an abstract type. We may access the constructors using Generic_core_desc.Variant.con_list
,
or using Generic_core_desc.Variant.cst
and Generic_core_desc.Variant.ncst
which respectively return
constant and non-constant constructors in the order that
they are listed in the datatype definition.
cst_get
and ncst_get
offer O(1) access to each constructor.val cons : 'v Generic_core_desc.Con.t list -> 'v cons
'v cons
from a list of constructor descriptions.
The constructors do not necessarily need to be given in
the same order as in the datatype definition, but it is
good practice to do so.
val unboxed_con : 'v Generic_core_desc.Con.t -> 'v cons
'v cons
from a single constructor.
unboxed_con
must be used only to represent unboxed variants.val cst_len : 'v cons -> int
cst_len cs
is the number of constant constructors in cs
.val cst_get : 'v cons -> int -> 'v Generic_core_desc.Con.t
cst_get cs i
returns the i
th constant constructors
of cs
(in the order of the datatype definition).
Indices start at 0
and end at cst_len cs - 1
.
Raises Invalid_argument
if i < 0
or i >= cst_len cs
val cst : 'v cons -> 'v Generic_core_desc.Con.t list
cst cs
returns the list of the constant constructors in cs
.val ncst_len : 'v cons -> int
ncst_len cs
is the number of non-constant constructors in cs
.val ncst_get : 'v cons -> int -> 'v Generic_core_desc.Con.t
ncst_get cs i
returns the i
th non-constant
constructors of cs
(in the order of the datatype
definition).
Indices start at 0
and end at ncst_len cs - 1
.
Raises Invalid_argument
if i < 0
or i >= ncst_len cs
val ncst : 'v cons -> 'v Generic_core_desc.Con.t list
ncst cs
returns the list of the non-constant constructors in cs
.val con_list : 'v cons -> 'v Generic_core_desc.Con.t list
cons
value. con_list (cons cs)
is a
permutation of cs
.val conap : 'v cons -> 'v -> 'v Generic_core_desc.Con.conap
Invalid_argument
if 'v cons
doesn't reflect all the possible
constructors of variant 'v
.
conap cs x = Conap (c,y) ==> c.embed y = x
type 'v
variant = {
|
name : |
|
module_path : |
|
cons : |
|
unboxed : |
name
the module in which it was defined and the set cons
of its constructors.type'v
t ='v variant