Module Make.Expert
module Snapshot : Bonsai__.Snapshot.S with module Event := Event
The underlying representations of Bonsai components. This module is provided "as is", without warranty of any kind, express or implied...
type ('input, 'model, 'action, 'result) unpacked
unpacked
exposes the action type of a component as an existential.
type ('input, 'model, 'result) t
= private
|
T : ('input, 'model, 'action, 'result) unpacked * 'action Core_kernel.Type_equal.Id.t -> ('input, 'model, 'result) t
Every Bonsai component has a hidden
'action
type, which can be revealed as an existential by pattern matching ont
.
val reveal : ('input, 'model, 'result) nonexpert_t -> ('input, 'model, 'result) t
reveal t
is just the identity, but it allows you to pattern match on the GADT to get the unpacked component (which you caneval
) and the action's type ID.
val conceal : ('input, 'model, 'result) t -> ('input, 'model, 'result) nonexpert_t
conceal
is the inverse ofreveal
.
val of_full : f:(input:'input Incr.t -> old_model:'model option Incr.t -> model:'model Incr.t -> inject:('action -> Event.t) -> ('model, 'action, 'result) Snapshot.t Incr.t) -> action_type_id:'action Core_kernel.Type_equal.Id.t -> ('input, 'model, 'result) t
Builds a component out of the incremental function from
'model Incr.t
toSnapshot.t Incr.t
. This function is in the expert module because it is effectively a black box to the rest of the Bonsai library, which meansoptimize
cannot do anything with it, for example.
val eval : input:'input Incr.t -> old_model:'model option Incr.t -> model:'model Incr.t -> inject:('action -> Event.t) -> action_type_id:'action Core_kernel.Type_equal.Id.t -> ('input, 'model, 'action, 'result) unpacked -> ('model, 'action, 'result) Snapshot.t Incr.t
Walks the component tree and builds a
Snapshot.t Incr.t
which will be recomputed whenmodel
andold_model
change.
val optimize : ('input, 'model, 'result) t -> ('input, 'model, 'result) t
Performs constant-folding and other optimizations on the component tree. This function is called once-per-component tree, which should be roughly once-per-application life-cycle unless there is dynamic component tree creation going on (perhaps via
of_full
andeval
).