Bonsai is an OCaml library for building and running pure, incremental, state-machines. It is primarily used as a foundational library for web applications, where immutable (virtual) representations of view are composed together with basic primitives.

Incrementality is used to reduce unnecessarily recomputing parts of the application, and compared to other frameworks that have incrementality at the view-computation level, Bonsai can incrementalize any subcomputation.

The "component" abstraction provided by Bonsai enables not only incrementalization of inputs and outputs, but also a powerful encapsulation of component-local state. Component-local state is private by default, but because components produce values of arbitrary types (not just views!), exposing state to other components is trivial.

This website contains the Bonsai Guide, but make sure to check out the project on github too!