Module Typerep.Record
type _ field
=
|
Field : ('record, 'a) Field.t -> 'record field
An existential type used to gather all the fields constituing a record type. the
'record
parameter is the record type, it is the same for all the field of that record type. The type of the fields might be different for each field and is thus existential.
type 'record fields
=
{
get : field. ('record, 'field) Field.t -> 'field;
}
'record fields
is a type isomorphic to'record
. This gives a way to get the field value for each field of the record. The advantage of this representation is that it is convenient for writing generic computations.
val typename_of_t : 'a t -> 'a Typerep_lib.Typename.t
val length : 'a t -> int
Returns the number of fields of this record type definition.
val has_double_array_tag : 'a t -> bool
This is a low level metadata regarding the way the ocaml compiler represent the array underneath that is the runtime value of a record of type
'a
given a witness of type'a t
.has_double_array_tag w
returnstrue
if the array that represents runtime values of this type is an optimized ocaml float array. Typically, this will be true for record where all fields are statically known as to befloats
.Note that you can't get this information dynamically by inspecting the typerep once it is applied, because there is at this point no way to tell whether one of the field is polymorphic in the type definition.
val create : 'a t -> 'a fields -> 'a
Expose one direction of the isomorphism between a value of type
'a
and a value of type'a fields
. Basically, given an encoding way of accessing the value of all the fields of a record, create that record and return it.
val fold : 'a t -> init:'acc -> f:('acc -> 'a field -> 'acc) -> 'acc
folding along the tags of the variant type
val internal_use_only : 'a Record_internal.t -> 'a t