1. Overview
  2. Docs
Module type
Class type
type _ field =
  1. | 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 = {
  1. 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.

type 'a t

Witness of a record type. The parameter is the type of the record type witnessed.

val typename_of_t : 'a t -> 'a Typename.t
val length : 'a t -> int

Returns the number of fields of this record type definition.

val field : 'a t -> int -> 'a field

Get the nth field of this record type, indexed from 0.

val has_double_array_tag : _ 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 returns true 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 be floats.

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