Gist.Meta
Gist metadata.
Metadata, found throughout the description, allows to associate arbitrary type-dependent key-value data to the description. Processors can create and expose new keys to allow descriptions to influence their outputs.
Since the key value can depend on the type of the type you describe the interface is slightly unusual compared to a classic heterogeneous dictionary. A 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 t = 'f fmt end)
module Meta_skip = Type.Gist.Meta.Key (struct type 'a 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
let meta : string Meta.t =
Type.Gist.Meta.empty |> Meta_fmt.add Format.pp_print_string
val make : doc:string -> 'a t
make ~doc
is Doc.add doc empty
.
val empty : 'a t
empty
is the empty metadata.
val is_empty : 'a t -> bool
is_empty m
is 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.
Key (V)
is a new key with values of type 'a V.t
.