Mavryk_stdlib.TagTags and tag sets. Tags are basically similar to a plain extensible variant type, but wrapped with metadata that enables them to be printed generically and combined into tag sets where each tag is either not present or associated with a specific value.
They are primarily intended for use with the `Logging` module but it would probably be reasonable to use them for other purposes.
Type of tag definitions. Analogous to a constructor of an extensible variant type, but first-class.
val def :
?doc:string ->
string ->
(Stdlib.Format.formatter -> 'a -> unit) ->
'a defDefine a new tag with a name, printer, and optional documentation string. This is generative, not applicative, so tag definitions created with identical names and printers at different times or places will be different tags! You probably do not want to define a tag in a local scope unless you have something really tricky in mind. Basically all the caveats you would have if you wrote type t += apply.
val name : 'a def -> stringval doc : 'a def -> stringval printer : 'a def -> Stdlib.Format.formatter -> 'a -> unitval pp_def : Stdlib.Format.formatter -> 'a def -> unitPrint the name of a tag definition.
A binding consisting of a tag and value. If a `def` is a constructor of an extensible variant type, a `t` is a value of that type.
val pp : Stdlib.Format.formatter -> t -> unitmodule Key : sig ... endTag sets. If `t` is an extensible variant type, `set` is a set of `t`s no two of which have the same constructor. Most ordinary set and map operations familiar from the OCaml standard library are provided. `equal` and `compare` are purposely not provided as there is no meaningful ordering on tags and their arguments may not even have a meaningful notion of equality.
val empty : setval is_empty : set -> boolval cardinal : set -> intval pp_set : Stdlib.Format.formatter -> set -> unitmodule DSL : sig ... endDSL for logging messages. Opening this locally makes it easy to supply a number of semantic tags for a log event while using their values in the human-readable text. For example: