Module Gist.Meta

Gist metadata.

Metadata is associated both to type gists and the fields of products. It allows to associate arbitrary type-dependent key-value data to the description. Gist processors can create and expose new keys to allow descriptions to influence their results. See for example the generic function metadata convention.

Since the dictionary value is polymorphic in the of the type of the gist or field you describe the interface is slightly unusual compared to a classic heterogeneous dictionary. A new key is the result of a functor instantiated with the data type of the value. For example:

  type 'a fmt = Format.formatter -> 'a -> unit
  module Meta_fmt = Type.Gist.Meta.Key (struct type ('a, 'b) t = 'b fmt end)
  module Meta_skip = Type.Gist.Meta.Key (struct type ('a, 'b) t = bool end)

you can then use the module's key interface to test key membership, add and remove data for the key. For example:

  let meta : int Meta.t =
    Type.Gist.Meta.empty
    |> Meta_fmt.add Format.pp_print_int
    |> Type.Gist.Meta.Min.add 0
    |> Type.Gist.Meta.Max.add 255
type ('p, 'f) t2

The type for metadata for types parameterized by 'p and 'f. Key values can depend on 'p and 'f. This is used for ('p, 'f) Field.t values. It allows to talk about both the product type 'p and the field type 'f.

type 'a t = ('a, 'a) t2

The type for metadata for types parameterized by 'a. Key values can depend on 'a. This is used for 'a Gist.t gist values. It allows to talk about the type 'a represented by the gist.

val empty : ('a, 'b) t2

empty is the empty metadata.

val is_empty : ('a, 'b) t2 -> bool

is_empty m is true iff m has no bindings.

module type VALUE = sig ... end

Type signature to describe the type dependent value of a type.

module type KEY = sig ... end

The type for key modules.

module Key (V : VALUE) : KEY with type ('a, 'b) value := ('a, 'b) V.t

Key (V) is a new key with values of type 'a V.t.

Standard keys

module Deprecated : KEY with type ('a, 'b) value := string

Deprecated is a key for indicating to processors that the type or field is subject to an @deprectated attribute with given payload

module Ignore : KEY with type ('a, 'b) value := bool

Ignore is a key for indicating to processors to ignore the type or field (they may or may not abide by it).

module Immediate : KEY with type ('a, 'b) value := bool

Immediate is a key for specifying that the type definition is subject to an [@immediate] attribute (if true).

module Immediate64 : KEY with type ('a, 'b) value := bool

Immediate64 is a key for specifying that the type definition is subject to an [@immediate64] attribute (if true).

module Min : KEY with type ('a, 'b) value = 'b

Min is a key to store a minimal value for the type or field value.

module Max : KEY with type ('a, 'b) value = 'b

Max is a key to store a maximal value for the type or field value.

module Unboxed : KEY with type ('a, 'b) value := bool

Unboxed is a key for specifying that the type definition is subject to an [@unboxed] attribute (if true) or an [@boxed] attribute (if false).