Module Gist.Field

Fields.

The field type represents an individual field of a Product.t value which is used to represent tuple types, record types and variant cases types.

Fields are named only for record types or variant case types with inline records.

Fields

type name = Gist.name

The type for record field names. These must be unqualified. For example for Stdlib.Complex, re, im, see also name. An empty string indicates the field is unnamed.

type ('p, 'v) t

The type for representing the field of type 'v of a product of type 'p.

val make : ?name:name -> ?doc:string -> ?meta:('p, 'v) Meta.t2 -> ?set:('p -> 'v -> unit) -> ?iset:('p -> 'v -> 'p) -> 'v gist -> ('p -> 'v) -> ('p, 'v) t

make g get is a field such that:

  • g is the type representation of the field.
  • get is the function to get the field value from the product.
  • name is the name for the field. Defaults to "".
  • doc is the doc string for the field. Defaults to "".
  • meta is the field metadata. Defaults to Meta.empty.
  • set is a function to update the field value of the product in-place for mutable record fields. Defaults to None, that is the field is immutable.
  • iset is a function for an immutable update of the field value of the product. Defaults to None.
val name : ('p, 'v) t -> name

name f is the name of f. This is "" on unnamed field.

val doc : ('p, 'v) t -> string

doc f is the doc string of f.

val meta : ('p, 'v) t -> ('p, 'v) Meta.t2

meta f is the meta of f.

val gist : ('p, 'v) t -> 'v gist

gist f is the gist of f.

val get : ('p, 'v) t -> 'p -> 'v

get f is the function to get the field value from the product.

val set : ('p, 'v) t -> ('p -> 'v -> unit) option

set f is a function to update the field value of the product in-place, if any. This is only relevant for record fields.

val iset : ('p, 'v) t -> ('p -> 'v -> 'p) option

iset f is a function for an immutable update of the field value of the product, if any.

val is_mutable : ('p, 'v) t -> bool

is_mutable f is true if and only if set f is Some _.