module Record:sig..end
Record factory.
You shall start by declaring a (ghost) type r and call
Record.signature to create a signature of type r, which will be
your container to register your record fields.
Then, populate the signature with Record.field or Record.option.
Finally, you shall call Record.publish to pack the record signature and
obtain a new data module of type Record with type r = r,
which gives you a Data with an opaque
type t = r record with fields of type (r,a) field.
(* ---- Exemple of Record Data --- *)
type r
let s = Record.signature () in
let fd_a = Record.field s ~name:"a" ~descr:"..." (module A) in
let fd_b = Record.field s ~name:"b" ~descr:"..." (module B) in
let r = Record.publish s ~page ~kind ~name ~descr
module M = (val r) : Record with type r = r)
let make a b = M.default |> M.set fd_a a |> M.set fd_b b
type 'a record
Records of type 'a.
type 'a signature
Opened signature for record of type 'a.
type ('a, 'b) field
Field of type 'b for a record of type 'a.
module type S =sig..end
Data with type t = r record.
val signature : unit -> 'a signatureCreate a new, opened record type.
val field : 'r signature ->
name:string ->
descr:Markdown.text ->
?default:'a -> 'a Data.data -> ('r, 'a) fieldAdds a field to an opened record.
val option : 'r signature ->
name:string ->
descr:Markdown.text -> 'a Data.data -> ('r, 'a option) fieldAdds a optional field to an opened record.
val publish : package:Package.package ->
name:string ->
?descr:Markdown.text ->
'a signature -> (module Data.Record.S with type r = 'a)Publish and close an opened record.