package bonsai

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

Module Bonsai.Arrow

('i, _, 'r) t is an arrow from 'i to 'r.

val arr : ('input -> 'result) -> ('input, 'result) t

arr is the same as pure.

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

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

                             .-----------------------.
                             | .-------------------. |
                .-- 'input --+-| 'input -> 'result |-+-- 'result --.
               /             | `-------------------` |              \
'input * 'a --+---------'a --+-----------------------+-- 'a ---------+-- 'result * 'a
                             `-----------------------`
val second : ('input, 'result) t -> ('a * 'input, 'a * 'result) t

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

                            .-----------------------.
                .----- 'a --+-----------------------+-- 'a -----.
               /            | .-------------------. |            \
'a * 'input --+--- 'input --+-| 'input -> 'result |-+-- 'result --+-- 'a * 'result
                            | `-------------------` |
                            `-----------------------`
val 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.

                             .-----------------.
                             | .-------------. |
                   .-- 'i1 --+-| 'i1 -> 'r1  |-+-- 'r1 --.
                  /          | `-------------` |          \
                 /           | .-------------. |           \
    'i1 * 'i2 --+----- 'i2 --+-| 'i2 -> 'r2  |-+-- 'r2 -----+-- 'r1 * 'r2
                             | `-------------` |
                             `-----------------`
val extend_first : ('input, 'result) t -> ('input, 'result * 'input) t

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

         .----------------------------.
         |      .-------------------. |
'input --+-+----| 'input -> 'result |-+-- 'result --.
         |  \   `-------------------` |              \
         |   `------------------------+-- 'input -----+-- 'result * 'input
         `----------------------------`
val extend_second : ('input, 'result) t -> ('input, 'input * 'result) t

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

         .----------------------------.
         |   .------------------------+-- 'input --.
         |  /   .-------------------. |             \
'input --+-+----| 'input -> 'result |-+-- 'result ---+-- 'input * 'result
         |      `-------------------` |
         `----------------------------`
val (***) : ('i1, 'r1) t -> ('i2, 'r2) t -> ('i1 * 'i2, 'r1 * 'r2) t

t *** u = split t u.

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

         .------------------------.
         |      .---------------. |
         |   .--| 'input -> 'r1 |-+-- 'r1 --.
         |  /   `---------------` |          \
'input --+-+                      |           \
         |  \   .---------------. |            \
         |   `--| 'input -> 'r2 |-+-- 'r2 ------+-- 'r1 * 'r2
         |      `---------------` |
         `------------------------`
val fanout : ('input, 'r1) t -> ('input, 'r2) t -> ('input, 'r1 * 'r2) t
val (&&&) : ('input, 'r1) t -> ('input, 'r2) t -> ('input, 'r1 * 'r2) t

t &&& u = fanout t u.

val (^>>) : ('i1 -> 'i2) -> ('i2, 'result) t -> ('i1, 'result) t

^>> is the same as @>>, but with a Haskell-like name.

val (>>^) : ('input, 'r1) t -> ('r1 -> 'r2) -> ('input, 'r2) t

>>^ is the same as >>|, but with a Haskell-like name.

val 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.

         .--------------------------------------------.
         |       .------------------------------.     |
         |    .--| 'input -> 'shared * 'output1 |--+--+-- 'output1 --.
         |   /   `------------------------------`  |  |               \
         |  /                                      |  |                \
'input --|-+     .---------- 'shared --------------`  |                 \
         |  \    |                                    |                  \
         |   \   |  .------------------------------.  |                   \
         |    `--+--| 'input * 'shared -> 'output2 |--+-- 'output2 --------+-- 'output1 * 'output2
         |          `------------------------------`  |
         `--------------------------------------------`
val pipe : ('input, 'r1) t -> into:('intermediate, 'r2) t -> via:('input -> 'r1 -> 'intermediate) -> finalize:('input -> 'r1 -> 'r2 -> 'r3) -> ('input, 'r3) t
OCaml

Innovation. Community. Security.