package typerep

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module M.FieldSource

Witness of a field, that is an item in a record type. The first parameter is the record type, the second is the type of the field. Example:

  type t = { x : int ; y : string }

This type has two fields. for each of them we'll have a corresponding Field.t

val field_x : (t, int) Field.t val field_y : (t, string) Field.t

Sourcetype ('record, 'field) t
Sourceval label : (_, _) t -> string

The name of the field as it is given in the concrete syntax Examples:

  { x   : int;     (* "x" *)
    foo : string;  (* "foo" *)
    bar : float;   (* "bar" *)
  }
Sourceval index : (_, _) t -> int

The 0-based index of the field in the list of all fields for this record type. Example:

  type t = {
    x   : int;     (* 0 *)
    foo : string;  (* 1 *)
    bar : string;  (* 2 *)
  }
Sourceval get : ('record, 'field) t -> 'record -> 'field

Field accessors. This corresponds to the dot operation. Field.get bar_field t returns the field bar of the record value t, just the same as t.bar

Sourceval is_mutable : (_, _) t -> bool

return whether the field is mutable, i.e. whether its declaration is prefixed with the keyword mutable

Sourceval tyid : (_, 'field) t -> 'field Typename.t

return the type_name of the arguments. Might be used to perform some lookup based on it

Sourceval traverse : (_, 'field) t -> 'field X.t

get the computation of the arguments

Sourceval internal_use_only : ('a, 'b) Field_internal.t -> ('a, 'b) t