Module Tenacious_lib.Tenacious.Var

A mutable variable whose state can be watched as a Tenacious computation. 'a Var.t is conceptually a 'a Ref.t with Var.{create,get,set,replace} corresponding to Ref.{create,(!),(:=),replace}. The important difference is the watch function, that lets you construct tenacious computations that depend on the value of the variable.

type 'a t
type 'a ten
val create : 'a ‑> 'a t
val watch : 'a t ‑> 'a ten

a tenacious computation whose value tracks the variable value

val set : 'a t ‑> 'a ‑> unit

Set new value for the variable. Any hearts derived from watch are broken immediately.

val get : 'a t ‑> 'a

Get the current value of the variable without watching it. Should be avoided in Tenacious computations. Use watch instead.

val replace : 'a t ‑> f:('a ‑> 'a) ‑> unit