package incremental

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type ('a, 'w) t
val sexp_of_t : ('a -> Sexplib0.Sexp.t) -> ('w -> Sexplib0.Sexp.t) -> ('a, 'w) t -> Sexplib0.Sexp.t
include Core.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
val observing : ('a, 'w) t -> ('a, 'w) incremental
val use_is_allowed : (_, _) t -> bool
val value : ('a, _) t -> 'a Core.Or_error.t

value t returns the current value of t, or Error if t does not currently have a stable value. In particular, value t will return Error in the following situations:

  • in the middle of stabilization.
  • if stabilize has not been called since t was created.
  • if disallow_future_use t has been called.
  • if observing t is invalid.

Rather than using value in a function that runs during stabilization, one should use map or bind to express the dependence of an incremental computation on an incremental.

val value_exn : ('a, _) t -> 'a
module Update : sig ... end
val on_update_exn : ('a, _) t -> f:('a Update.t -> unit) -> unit

on_update_exn t ~f calls f after the current stabilization and after each subsequent stabilization in which t changes, until disallow_future_use t is called. f will be called at most once per stabilization. Here is a state diagram for the allowable sequences of Update.t's that can be supplied to a particular f:

           /-----------------------------------------------------\
           |                 /                                   |
           |                 |                                   v
          Start ------> Initialized ------> Changed ------> Invalidated
                                              ^  |
                                              \--/

on_update_exn raises if disallow_future_use t was previously called.

val disallow_future_use : (_, _) t -> unit

After disallow_future_use t:

  • on_update_exn t and value_exn t will raise, and value t will return Error.
  • t's on-update handlers will never run again.
  • At the next call to stabilize, before recomputing nodes, incremental will mark t as unobserved, and mark as unnecessary all nodes that were necessary only to maintain t.
OCaml

Innovation. Community. Security.