summaryrefslogtreecommitdiff
path: root/lib/value/value.ml
diff options
context:
space:
mode:
authorSébastien Dailly <sebastien@dailly.me>2026-11-20 16:23:53 +0100
committerSébastien Dailly <sebastien@dailly.me>2026-11-20 16:23:53 +0100
commitb05e2d2be7be28ee6c577671002797cf9abaf177 (patch)
tree0474684d619721024f0a6cb132cf2f4d2e84c344 /lib/value/value.ml
parentc4ca180fd7c2085e3ce3f8e32aa0c2cb724f4c53 (diff)
New module for working with Values
Diffstat (limited to 'lib/value/value.ml')
-rw-r--r--lib/value/value.ml34
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/value/value.ml b/lib/value/value.ml
new file mode 100644
index 0000000..38c2240
--- /dev/null
+++ b/lib/value/value.ml
@@ -0,0 +1,34 @@
+module Fields = Fields
+
+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] *)
+
+(** A resolved field data: the data of a field of a content or a list, whatever
+ the type of the data held *)
+type value = Model.target Data.any
+
+let none : value = Data.any Data.none
+
+let single : ('a, Model.target) Model.Typ.t * 'a -> value =
+ fun data -> Data.any (Data.v data)
+
+let multi : (int64, Model.target) Model.Typ.t * int64 Seq.t -> value =
+ fun data -> Data.any (Data.seq data)
+
+(** A value: one row of a content or list table in the database.
+
+ The type 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]). *)
+type 'a t = {
+ content : 'a;
+ (** The content or list whose table holds the row *)
+ id : int64;
+ (** The primary key of the row *)
+}
+
+let v : 'a -> int64 -> 'a t = fun content id -> { content; id }
+let content : 'a t -> 'a = fun t -> t.content
+let id : 'a t -> int64 = fun t -> t.id