module Enum:sig..end
You shall start by declaring a dictionary with Enum.dictionary for your
values. Then, populate the dictionary with Enum.tag values. Finally, you
shall call Enum.publish to obtain a new data module for your type.
You have two options for computing tags: either you provide values when
declaring tags, and these tags will be associated to registered values for
both directions; alternatively you might provide a ~tag function to
Enum.publish.
The difficulty when providing values only at tag definition is to ensure that all possible value has been registered.
The conversion values from and to json may fail when no value has been
registered with tags.
type 'a dictionary
type 'a tag
type 'a prefix
val tag_name : 'a tag -> string
val dictionary : page:Doc.page ->
name:string ->
title:string -> descr:Markdown.text -> unit -> 'a dictionaryval tag : 'a dictionary ->
name:string ->
?label:Markdown.text ->
descr:Markdown.text -> ?value:'a -> unit -> 'a tag~tag
function is provided when publishing the dictionary.
Registered values must be hashable with Hashtbl.hash function.
You may register a new tag after the dictionary has been published.
val prefix : 'a dictionary ->
prefix:string ->
?var:string ->
?label:Markdown.text -> descr:Markdown.text -> unit -> 'a prefix'prefix:*'.
The variable part of the prefix is documented as 'prefix:xxx'
when ~var:"xxx" is provided.
You may register a new prefix-tag after the dictionary has
been published.
val instance : 'a prefix -> string -> 'a tagval extends : 'a dictionary ->
'a prefix ->
name:string ->
?label:Markdown.text ->
descr:Markdown.text -> ?value:'a -> unit -> 'a tag : 'a dictionary -> Data.Tag.t listval page : 'a dictionary -> Doc.page
val name : 'a dictionary -> string
val syntax : 'a dictionary -> Markdown.text
val publish : 'a dictionary ->
?tag:('a -> 'a tag) -> unit -> (module Data.S with type t = 'a)~tag function is provided, registered values with tags are used.