module Record:sig
..end
You shall start by declaring a (ghost) type r
and call
Record.signature
to create a signature of type r
.
Then, populate the record with Record.field
or Record.option
.
Finally, you shall call Record.publish
to 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 ~page ~kind ~name ~descr () 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
module M = (val (Record.publish s) : Record with type r = r)
let make a b = M.default |> M.set fd_a a |> M.set fd_b b
module type S =sig
..end
type t = r record
.
val signature : page:Doc.page ->
name:string -> descr:Markdown.text -> unit -> 'a Data.signature
val field : 'r Data.signature ->
name:string ->
descr:Markdown.text -> ?default:'a -> 'a Data.data -> ('r, 'a) Data.field
val option : 'r Data.signature ->
name:string ->
descr:Markdown.text -> 'a Data.data -> ('r, 'a option) Data.field
val publish : 'a Data.signature -> (module Data.Record.S with type r = 'a)