Module Tnode.Prec_cell

A node's delayed precision, sealed (gh-ocannl-1624) together with the storage precision it settles into: read with get, written only by the guarded update_prec / update_infer_prec -- which update_prec and update_infer_prec wrap -- each write that changes the value reported to prec_write_hook. storage is the node's storage_prec, forced from the value; once it is forced, update_prec only validates and update_infer_prec refuses. The cell owns that lazy, so no caller can hand the guard a different one.

type t
val sexp_of_t : t -> Sexplib0.Sexp.t
val make : ?stated:Ops.prec Base.option Lazy.t -> delayed_prec -> t

stated is, for a node inferred bottom-up, the promotion of what its operands state (gh-ocannl-2028): None inside the lazy when no operand states a precision.

val get : t -> delayed_prec
val stated : t -> Ops.prec Base.option

The precision something states for this cell: its specified precision, else what its operands state (make's stated). None for a free cell: a top-down cell nothing specified, or a bottom-up cell none of whose operands, transitively, states a precision.

val storage : t -> Ops.prec Lazy.t
val update_prec : ?only_if:(Ops.prec -> Base.bool) -> name:(Base.unit -> Base.string) -> t -> Ops.prec -> Base.unit
val update_infer_prec : ?only_if:(Ops.prec -> Base.bool) -> name:(Base.unit -> Base.string) -> t -> Ops.prec Lazy.t -> Base.unit
val follow : ?only_if:(Ops.prec -> Base.bool) -> name:(Base.unit -> Base.string) -> t -> Ops.prec Lazy.t -> Base.unit

update_infer_prec for a link whose target may itself be inferred from readers of this cell (gh-ocannl-1967: an initializer's node following its parameter). The cell keeps the precision it would have settled into without the link, which is what bottom_up then answers, so the link closes no cycle through a bottom-up reader.

val follow_if_free : name:(Base.unit -> Base.string) -> t -> Ops.prec Lazy.t -> Base.unit

follow of a float cell by a consumer's precision, which the cell takes only if it is free (stated is None) and the consumer's precision is a float, both decided when the cell settles (gh-ocannl-2028); otherwise the link promotes by the cell's own value, changing nothing.

val bottom_up : t -> Ops.prec

The precision a consumer promoting from its operands reads: the storage precision, except for a cell that follows another and holds no specified precision, which answers the precision it had before the link. Forces what it answers.

type snapshot

The cell's value at a checkpoint, bound to the cell (gh-ocannl-903).

val snapshot : t -> snapshot
val restore : snapshot -> Base.unit

Puts the recorded value back, as a counted write.

val settling_began_since : snapshot -> Base.bool

Whether forcing the cell's storage began after the snapshot -- returned or raised: either way its lazy is memoized, and no rewind can reset it.

val snapshot_changed : snapshot -> Base.bool

Whether the value differs (physically) from the recorded one: a diagnostic.