Module Gist.Field

Operating on fields.

Fields represent components of products which are used to represent OCaml's tuples, records and variants cases.

Fields

type 'a gist := 'a t
type ('p, 'f) t = ('p, 'f) field

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

val make : ?meta:'f Meta.t -> ?name:string -> ?inject:('p -> 'f -> 'p) -> ?set:('p -> 'f -> unit) -> ?default:'f -> 'f gist -> ('p -> 'f) -> ('p, 'f) field

v g project is a field such that:

  • g is the type representation of the field.
  • project projects the field value from the product.
  • meta is the metadata (defaults to Meta.empty).
  • name is the name for the field (defaults to ""). For record fields this is the field name. For variant case this is the case name. For tuples this is the empty string or a name for a type abbreviation.
  • inject is an immutable update function to update the field of the prodcut (defaults to None).
  • set is a mutable update function to set the field of the product, for mutable record fields (defaults to None).
  • default is a default value for the dimension (defaults to None).
val meta : ('p, 'f) field -> 'f Meta.t

meta f is the meta of f.

val name : ('p, 'f) field -> string

name f is the name of f (if any).

val gist : ('p, 'f) field -> 'f gist

gist f is the gist of f.

val project : ('p, 'f) field -> 'p -> 'f

project f is the projection function of f.

val inject : ('p, 'f) field -> ('p -> 'f -> 'p) option

inject f is the optional immutable function of f.

val set : ('p, 'f) field -> ('p -> 'f -> unit) option

set f is the optional mutable function of f.

val default : ('p, 'f) field -> 'f option

default f is a default value for the field.