blob: bdacf5436efaafda9400063257208f7c4fb7cbe8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
(** 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]
(** 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 v : (unit -> target Content.t) -> t = fun f -> T (lazy (f ()))
let get : t -> target Content.t = fun (T target) -> Lazy.force target
|