Module Incremental__Bind

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 nodes 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__Types.Bind.t = {
main : 'b Incremental__Types.Node.t;
mutable f : 'a -> 'b Incremental__Types.Node.t;
lhs : 'a Incremental__Types.Node.t;
lhs_change : unit Incremental__Types.Node.t;
mutable rhs : 'b Incremental__Types.Node.t Incremental__.Import.Uopt.t;
mutable rhs_scope : Incremental__Types.Scope.t;
mutable all_nodes_created_on_rhs : Incremental__Types.Node.Packed.t Incremental__.Import.Uopt.t;
}
include Core_kernel.Invariant.S2 with type ('a, 'b) t := ('a'b) t
type ('a, 'b) t
val invariant : 'a Base__.Invariant_intf.inv -> 'b Base__.Invariant_intf.inv -> ('a'b) t Base__.Invariant_intf.inv
include Incremental__.Sexp_of.S2 with type ('a, 'b) t := ('a'b) t
type ('a, 'b) t
val sexp_of_t : ('a -> Ppx_sexp_conv_lib.Sexp.t) -> ('b -> Ppx_sexp_conv_lib.Sexp.t) -> ('a'b) t -> Ppx_sexp_conv_lib.Sexp.t
val is_valid : (__) t -> bool

is_valid t iff the scope in which t was created is valid.

val iter_nodes_created_on_rhs : (__) t -> f:(Incremental__.Types.Node.Packed.t -> unit) -> unit