diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-21 12:09:42 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-21 12:09:42 +0100 |
| commit | 9f2a57603dbfce428af36e82fb1c7cdc6e1ad0da (patch) | |
| tree | 0cc25d9b330d06a260fc3428646b3014a7ab8366 /lib/model | |
| parent | ce13c93cf14cb71894481b0303a7058a72a6f4ce (diff) | |
Load works for list and content values
Diffstat (limited to 'lib/model')
| -rw-r--r-- | lib/model/reference.ml | 15 | ||||
| -rw-r--r-- | lib/model/reference.mli | 3 |
2 files changed, 12 insertions, 6 deletions
diff --git a/lib/model/reference.ml b/lib/model/reference.ml index bdacf54..38d4346 100644 --- a/lib/model/reference.ml +++ b/lib/model/reference.ml @@ -6,12 +6,15 @@ type t = T : target Content.t Lazy.t -> t [@@unboxed] (** The target of a reference field, resolved: either a lazy pointer to a content, or a static list. The list case carries the list itself, whose own - fields are typed with this very [target] — references inside a list can - only target other lists (enforced by the configuration reader). *) -and target = - | Content of t - | List of target Data_list.t + fields are typed with this very [target] — references inside a list can only + target other lists (enforced by the configuration reader). *) +and target = Content of t | List of target Data_list.t let v : (unit -> target Content.t) -> t = fun f -> T (lazy (f ())) - let get : t -> target Content.t = fun (T target) -> Lazy.force target + +(** Reify an already resolved content as a {!target} — the lazy pointer is + created on the fly and only forced when needed (e.g. to read the row back) +*) +let of_content : target Content.t -> target = + fun content -> Content (v (fun () -> content)) diff --git a/lib/model/reference.mli b/lib/model/reference.mli index 2f9659b..09f70c5 100644 --- a/lib/model/reference.mli +++ b/lib/model/reference.mli @@ -8,3 +8,6 @@ and target = val v : (unit -> target Content.t) -> t val get : t -> target Content.t + +val of_content : target Content.t -> target +(** Reify an already resolved content as a {!target} *) |
