A module internal to Incremental. Users should see Incremental_intf.
An ('a, 'b) Bind.t
is stored inside a bind node where the left-hand side is
of type 'a
, and the right-hand side is of type 'b Node.t
.
Each bind t
has t.lhs_change : unit Node.t
that is used to detect when t.lhs
changes. Computing t.lhs_change
restructures the graph by calling t.f
and
replacing t.rhs
with the result.
Each bind tracks the set of nodes created on its right-hand side, as a singly-linked
list t.all_nodes_created_on_rhs
. This is used to invalidate all those nodes when
the t.lhs
changes.
The key invariant of a bind node t
is:
t.lhs_change.height < node.height
for all necessary node
s in
t.all_nodes_created_on_rhs
.
This ensures that a node created on the right-hand side is not computed unless the left-hand side is stable.
The graph manipulation done when t.lhs_change
fires can't be done when t.lhs
fires, because t.main
could be itself created inside a bind, and this bind's lhs is
not guaranteed to be stable when t.lhs
fires (but it is guaranteed to be stable when
t.lhs_change
fires).
include module type of sig ... end
type ('a, 'b) t
= ('a, 'b) Incremental_kernel__Types.Bind.t
=
{
main : 'b Incremental_kernel__Types.Node.t; |
mutable f : 'a ‑> 'b Incremental_kernel__Types.Node.t; |
lhs : 'a Incremental_kernel__Types.Node.t; |
lhs_change : unit Incremental_kernel__Types.Node.t; |
mutable rhs : 'b Incremental_kernel__Types.Node.t Incremental_kernel__.Uopt.t; |
mutable rhs_scope : Incremental_kernel__Types.Scope.t; |
mutable all_nodes_created_on_rhs : Incremental_kernel__Types.Packed_node.t Incremental_kernel__.Uopt.t; |
}
include Core_kernel.Invariant.S2 with type (a, b) t := (a, b) t
val invariant : 'a Base__.Invariant_intf.inv ‑> 'b Base__.Invariant_intf.inv ‑> ('a, 'b) t Base__.Invariant_intf.inv
include Incremental_kernel__.Sexp_of.S2 with type (a, b) t := (a, b) t
include sig ... end
val sexp_of_t : ('a ‑> Sexplib.Sexp.t) ‑> ('b ‑> Sexplib.Sexp.t) ‑> ('a, 'b) t ‑> Sexplib.Sexp.t
val iter_nodes_created_on_rhs : (_, _) t ‑> f:(Incremental_kernel__.Types.Packed_node.t ‑> unit) ‑> unit