From 8708171877054c98aad45079d85d4e699420f2fe Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Thu, 19 Nov 2026 11:32:16 +0100 Subject: Added fields in lists --- lib/model/reference.ml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'lib/model/reference.ml') diff --git a/lib/model/reference.ml b/lib/model/reference.ml index 67bbcaf..bdacf54 100644 --- a/lib/model/reference.ml +++ b/lib/model/reference.ml @@ -1,11 +1,17 @@ -(** A lazy pointer to a resolved content. The payload is - [t Typ.target Content.t] — i.e. {!Model.content} — and is only forced once - every content has been registered (see [Configuration.Ast.check]), which - is what allows cyclic references between contents. *) -type t = T : t Typ.target Content.t Lazy.t -> t [@@unboxed] +(** A lazy pointer to a resolved content. The payload is [target Content.t] — + i.e. {!Model.content} — and is only forced once every content has been + registered (see [Configuration.Ast.check]), which is what allows cyclic + references between contents. *) +type t = T : target Content.t Lazy.t -> t [@@unboxed] -let v : (unit -> t Typ.target Content.t) -> t = - fun f -> T (lazy (f ())) +(** 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 -let get : t -> t Typ.target Content.t = fun (T target) -> - Lazy.force target +let v : (unit -> target Content.t) -> t = fun f -> T (lazy (f ())) + +let get : t -> target Content.t = fun (T target) -> Lazy.force target -- cgit v1.2.3