From b05e2d2be7be28ee6c577671002797cf9abaf177 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Fri, 20 Nov 2026 16:23:53 +0100 Subject: New module for working with Values --- lib/value/value.mli | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 lib/value/value.mli (limited to 'lib/value/value.mli') diff --git a/lib/value/value.mli b/lib/value/value.mli new file mode 100644 index 0000000..42482f7 --- /dev/null +++ b/lib/value/value.mli @@ -0,0 +1,46 @@ +(** Operations on the values stored in the database (fetching, updating, …). + + A value is one row of a content or list table in the database. *) + +module Fields = Fields +(** The fields of a value, each with its associated data *) + +module Data = Data +(** The data carried by a field: {!Data.data}, parameterized over the type of + the data held, built with the smart constructors ([Data.none], [Data.v], + [Data.seq]); and {!Data.any}, the existential pack used when the held type + is not known statically *) + +type value = Model.target Data.any +(** The data of a field of a content or a list, whatever the type of the data + held: an existential pack over {!Data.data} *) + +val none : value +(** [none]: the field is empty (or left as is, on update) *) + +val single : ('a, Model.target) Model.Typ.t * 'a -> value +(** [single (typ, data)]: a single value for the field, together with the type + [typ] of the field *) + +val multi : (int64, Model.target) Model.Typ.t * int64 Seq.t -> value +(** [multi (typ, ids)]: a sequence of references for a multivalued field *) + +type 'a t +(** A value: a row of the table of the content or list ['a], identified by its + [id]. + + The parameter ['a] is the content or the static list whose table holds the + row: [Model.content] for contents ([Model.content Value.t]) and [Model.list] + for lists ([Model.list Value.t]). + + The type is abstract: a value is built with [v] and inspected with [content] + and [id]. *) + +val v : 'a -> int64 -> 'a t +(** Build a value from its content or list and its row id *) + +val content : 'a t -> 'a +(** The content or list the value belongs to *) + +val id : 'a t -> int64 +(** The primary key of the value in its table *) -- cgit v1.2.3