package bonsai

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Bonsai.Arrow_deprecatedSource

Sourcetype ('input, 'result) t = 'input Value.t -> 'result Computation.t
Sourcemodule type Model = sig ... end
Sourcemodule type Action = sig ... end
Sourceval const : 'result -> (_, 'result) t

const creates a Bonsai component with an unchanging output. It does not have an input, or a model. Constant components are not frequently used, but can be handy when using an API that requires a Bonsai.t, and you want the result to be constant.

This function is approximately the same as Fn.const.

Sourceval input : ('result, 'result) t

input is the identity function as a Bonsai component.

Sourceval pure : f:('input -> 'result) -> ('input, 'result) t

pure is used to create a Bonsai component that can be implemented as a pure function from 'input to 'result

Sourceval compose : ('input, 's) t -> ('s, 'result) t -> ('input, 'result) t

compose (and the >>> infix operator) connect the output from one component into the input of another component. This is conceptually similar to function composition: Fn.compose.

Sourceval map : ('input, 'r1) t -> f:('r1 -> 'r2) -> ('input, 'r2) t

map (and the >>| infix operator ) transforms the result type of a Bonsai component using the provided function.

Sourceval map_input : ('i2, 'result) t -> f:('i1 -> 'i2) -> ('i1, 'result) t

map_input (and the @>> infix operator) transforms the input type of a Bonsai component using the provided function.

Sourceval of_module : (module Bonsai__.Import.Component_s with type Action.t = 'action and type Input.t = 'input and type Model.t = 'model and type Result.t = 'result) -> default_model:'model -> ('input, 'result) t

of_module is one of the most commonly used component constructors. The function takes a first-class module of type Component_s, as well as the default model for the component. For more details, please read the docs for Component_s.

Sourceval both : ('input, 'r1) t -> ('input, 'r2) t -> ('input, 'r1 * 'r2) t

Given two components that have the same input, both returns a Bonsai component that contains both of their outputs.

Sourceval state_machine : (module Model with type t = 'model) -> (module Action with type t = 'action) -> Core.Source_code_position.t -> default_model:'model -> apply_action: (inject:('action -> unit Ui_effect.t) -> schedule_event:(unit Ui_effect.t -> unit) -> 'input -> 'model -> 'action -> 'model) -> ('input, 'model * ('action -> unit Ui_effect.t)) t

state_machine is a function that is used to define a component solely in terms of its apply_action function. The result value of the component is the value of the current model alongside an injection function to transition the state machine

Sourceval enum : (module Bonsai__.Module_types.Enum with type t = 'key) -> which:('input -> 'key) -> handle:('key -> ('input, 'result) t) -> ('input, 'result) t

enum is how a Bonsai component can branch on its input and handle different cases with a different Bonsai component.

The which function translates cases from the components input into values of type 'key.

The handle function translates the values returned by which into the component that handles this value.

Sourceval if_ : ('input -> bool) -> then_:('input, 'result) t -> else_:('input, 'result) t -> ('input, 'result) t

if_ is a special case of enum for booleans.

Sourcemodule type S = sig ... end
Sourcemodule Map : sig ... end
Sourceval arr : ('a -> 'b) -> ('a, 'b) t

arr is the same as pure.

Sourceval (>>^) : ('a, 'b) t -> ('b -> 'c) -> ('a, 'c) t

The same as map

Sourceval (^>>) : ('a, 'b) t -> ('c -> 'a) -> ('c, 'b) t

The same as map_input

Sourceval first : ('input, 'result) t -> ('input * 'a, 'result * 'a) t

first t applies t to the first part of the input.

Sourceval second : ('input, 'result) t -> ('a * 'input, 'a * 'result) t

second t applies t to the second part of the input.

Sourceval split : ('i1, 'r1) t -> ('i2, 'r2) t -> ('i1 * 'i2, 'r1 * 'r2) t

split t u applies t to the first part of the input and u to the second part.

Sourceval extend_first : ('input, 'result) t -> ('input, 'result * 'input) t

extend_first returns the result of a Bonsai component alongside its input.

Sourceval extend_second : ('input, 'result) t -> ('input, 'input * 'result) t

extend_second returns the result of a Bonsai component alongside its input.

Sourceval fanout : ('input, 'r1) t -> ('input, 'r2) t -> ('input, 'r1 * 'r2) t

fanout t u applies t and u to the same input and returns both results. It's actually just both.

Sourceval (***) : ('i1, 'r1) t -> ('i2, 'r2) t -> ('i1 * 'i2, 'r1 * 'r2) t

t *** u = split t u.

Sourceval (&&&) : ('input, 'r1) t -> ('input, 'r2) t -> ('input, 'r1 * 'r2) t

t &&& u = fanout t u.

Sourceval partial_compose_first : ('input, 'shared * 'output1) t -> ('input * 'shared, 'output2) t -> ('input, 'output1 * 'output2) t

Composes two components where one of the outputs of the first component is one of the inputs to the second.

Sourceval pipe : ('input, 'r1) t -> into:('intermediate, 'r2) t -> via:('input -> 'r1 -> 'intermediate) -> finalize:('input -> 'r1 -> 'r2 -> 'r3) -> ('input, 'r3) t

pipe connects two components, but provides several functions that ease the transference of data between the components, as well as collect the final result.

Sourcemodule With_incr : sig ... end
Sourcemodule Infix : sig ... end
Sourcemodule Let_syntax : sig ... end