package bonsai

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type 'a t

A value of type 'a Value.t represents a value that may change during the lifetime of the program. For those familiar with the Incremental library, this type is conceptually very similar to Incr.t. The main method by which you acquire values of type Value.t is by using the let%sub syntax extension.

val c : int Computation.t

let%sub x = c in
(* [x] has type [int Value.t] here *)

In the example above, we run a computation c and store the result of that computation in x which has type Value.t.

Value.t is an applicative, which means that you can combine multiple Values into one by using Let_syntax:

val a : int Value.t
val b : int Value.t

let open Let_syntax in
let%map a = a and b = b in
a + b
include Core.Applicative.S with type 'a t := 'a t
val return : 'a -> 'a t
val map : 'a t -> f:('a -> 'b) -> 'b t
val both : 'a t -> 'b t -> ('a * 'b) t
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t

same as apply

val (<*) : 'a t -> unit t -> 'a t
val (*>) : unit t -> 'a t -> 'a t
val (>>|) : 'a t -> ('a -> 'b) -> 'b t
val apply : ('a -> 'b) t -> 'a t -> 'b t
val map2 : 'a t -> 'b t -> f:('a -> 'b -> 'c) -> 'c t
val all : 'a t list -> 'a list t
val all_unit : unit t list -> unit t
module Applicative_infix : sig ... end
val map3 : 'a1 t -> 'a2 t -> 'a3 t -> f:('a1 -> 'a2 -> 'a3 -> 'b) -> 'b t
val map4 : 'a1 t -> 'a2 t -> 'a3 t -> 'a4 t -> f:('a1 -> 'a2 -> 'a3 -> 'a4 -> 'b) -> 'b t
val map5 : 'a1 t -> 'a2 t -> 'a3 t -> 'a4 t -> 'a5 t -> f:('a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'b) -> 'b t
val map6 : 'a1 t -> 'a2 t -> 'a3 t -> 'a4 t -> 'a5 t -> 'a6 t -> f:('a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'b) -> 'b t
val map7 : 'a1 t -> 'a2 t -> 'a3 t -> 'a4 t -> 'a5 t -> 'a6 t -> 'a7 t -> f:('a1 -> 'a2 -> 'a3 -> 'a4 -> 'a5 -> 'a6 -> 'a7 -> 'b) -> 'b t
val cutoff : 'a t -> equal:('a -> 'a -> bool) -> 'a t

A Value.t transformed by cutoff will only trigger changes on its dependents when the equality of the contained value has changed.

Immediate nesting of cutoff nodes are combined into a single cutoff node whose equality function is true when any of the composed nodes is true and is false when all of the composed nodes are false. They're "or'ed together".

OCaml

Innovation. Community. Security.