Module Bonsai.Generic
type on_action_mismatch=[|`Ignore|`Raise|`Warn]type ('input, 'result, 'incr, 'event) t= ('input, 'result, 'incr, 'event) Bonsai_types.Packed.tThe component type (
('input, 'result) Bonsai.t) can be thought of as a function from'modelto'result, but where the'resultcan schedule events of the component's "action type". These actions are used to produce a new'modelwhich in turn causes the'resultto be recomputed. Instances of the'resulttype can contain callbacks which schedule actions when interacted with by user (via button click, text input, etc). These actions are handled by the component'sapply_actionfunction, which yields a new model to be displayed.
type ('input, 'result, 'incr, 'event) nonexpert_t:= ('input, 'result, 'incr, 'event) t
val sexp_of_t : (_, _, _, _) t -> Core_kernel.Sexp.t
Component Constructors
val const : 'result -> (_, 'result, 'incr, _) tReturns a component with no action or model, only a constant result.
val pure : f:('input -> 'result) -> ('input, 'result, _, _) tA pure function with no model from 'input to 'result
val leaf : (module Bonsai__.Bonsai_intf.Model with type t = 'model) -> (module Bonsai__.Bonsai_intf.Action with type t = 'action) -> name:string -> default_model:'model -> apply_action:(inject:('action -> 'event) -> schedule_event:('event -> unit) -> 'input -> 'model -> 'action -> 'model) -> compute:(inject:('action -> 'event) -> 'input -> 'model -> 'result) -> ('input, 'result, 'incr, 'event) tCreates a leaf-node on the Bonsai tree. A leaf node has computation (via the
computeparameter) and behavior (via theapply_actionparameter).Additionally
nameandsexp_of_actionare provided to add some hooks for improved debugability.
val compose : ('i1, 'r1, 'incr, 'event) t -> ('r1, 'r2, 'incr, 'event) t -> ('i1, 'r2, 'incr, 'event) tcompose a bjoinsaandbtogether such that the result ofais used as the input ofb.
module type Enum = sig ... endval enum : (module Enum with type t = 'key) -> which:('input -> 'key) -> handle:('key -> ('input, 'result, 'incr, 'event) t) -> ('input, 'result, 'incr, 'event) tval if_ : ('input -> bool) -> then_:('input, 'result, 'incr, 'event) t -> else_:('input, 'result, 'incr, 'event) t -> ('input, 'result, 'incr, 'event) tif_is a simple application ofenumto(module Bool).
module Infix : sig ... endval map : ('input, 'r1, 'incr, 'event) t -> f:('r1 -> 'r2) -> ('input, 'r2, 'incr, 'event) tval map_input : ('i2, 'result, 'incr, 'event) t -> f:('i1 -> 'i2) -> ('i1, 'result, 'incr, 'event) tTransforms the input of a component. The signature of
fis reversed from most other map functions.
module Proc : sig ... endmodule Let_syntax : sig ... endmodule Expert : sig ... endCombinators
val state_machine : (module Bonsai__.Bonsai_intf.Model with type t = 'model) -> (module Bonsai__.Bonsai_intf.Action with type t = 'action) -> Core_kernel.Source_code_position.t -> default_model:'model -> apply_action:(inject:('action -> 'event) -> schedule_event:('event -> unit) -> 'input -> 'model -> 'action -> 'model) -> ('input, 'model * ('action -> 'event), 'incr, 'event) t
module Map : sig ... endmodule List_deprecated : sig ... endmodule Arrow : sig ... endmodule With_incr : sig ... end