Legend:
Library
Module
Module type
Parameter
Class
Class type
Bonsai can be used with any Incremental-style UI framework. The parameters for the Bonsai component functor are an instance of Incremental (used to re-evaluate the UI only when the UI model has changed) and an opaque Event.t type (which is used to schedule actions).
The recommended use of this functor is to bind the name Bonsai to its invocation. For example, Bonsai_web's import.ml has:
The component type (('model, 'result) Bonsai.t) can be thought of as a function from 'model to 'result, but where the 'result can schedule events of the component's "action type". These actions are used to produce a new 'model which in turn causes the 'result to be recomputed. Instances of the 'result type can contain callbacks which schedule actions when interacted with by user (via button click, text input, etc). These actions are handled by the component's apply_action function, which yields a new model to be displayed.
For composing components which share the same model. For example, applying an action in one component changes the shared model, which is reflected in the results of the other component.
Projecting over lists in Bonsai is fraught with issues. 1. Incremental can't be optimized for linked-list data structures. 2. Using list-index as the method for routing actions to components is basically never what you actually want, causing mis-delivery of events every time that the list changes.