Module Bonsai_proc.Expert

val thunk : here:lexing_position -> (unit -> 'a) -> 'a Computation.t

thunk will execute its argument exactly once per instantiation of the computation.

val assoc_on : here:lexing_position -> ('io_key, 'io_cmp) Core.Comparator.Module.t -> ('model_key, 'model_cmp) Core.Comparator.Module.t -> ('io_key, 'data, 'io_cmp) Core.Map.t Value.t -> get_model_key:('io_key -> 'data -> 'model_key) -> f:('io_key Value.t -> 'data Value.t -> 'result Computation.t) -> ('io_key, 'result, 'io_cmp) Core.Map.t Computation.t

assoc_on is similar to assoc, but allows the model to be keyed differently than the input map. This comes with a few caveats:

  • Inputs whose keys map to the same model_key will share the same model.
  • The result of get_model_key is used in a bind, so it is expensive when it changes.

assoc should almost always be used instead. Consider whether you really need the additional power before reaching for this function.