Module Gist.Product

Operating on products.

Products

type 'p t = 'p product

The type for products.

val make : ?meta:'p Meta.t -> ?name:string -> ('p, 'p) fields -> 'p product

make fields is a product with:

  • fields the ordered sequence of fields of the product.
  • meta is the metadata (defaults to Meta.empty).
  • name the name of the product (defaults to ""). For records this is the type name. For variant cases this is the case constructor name. For products, if non empty, this is the type name of a type abbreviation.
val meta : 'p product -> 'p Meta.t

meta p is the metadata of p.

val name : 'p product -> string

name p is the name of p (if any). For records or products this is the type name for variant cases this is the case name.

val fields : 'p product -> ('p, 'p) fields

fields p are the fields of p.

val is_empty : 'p product -> bool

is_empty p is true if p has no fields.

val is_singleton : 'p product -> bool

is_singleton p is true if p has a single field.

val rec_field_count : 'p product -> int

rec_field_count c is the number of recursive fields in c.

val with_meta : 'p Meta.t -> 'p product -> 'p product

with_meta meta p is p with meta meta.

Constructing description

This intermediate structure is used for constructing product descriptions.

type ('p, 'ctor) cons

The type for constructing product decriptions.