Bitbucket is a code hosting site with unlimited public and private repositories. We're also free for small teams!

Close

Bufx: Passive Buffered Transforms

This mini-library provides (packed in Bufx) the module Transform which implements the API defined in TRANSFORM.

Bufx.Transform.t is a container for buffered transformations over streams modeled in the style of the Cryptokit library for the Biocaml project (see the biocaml application for extensive use —and testing— of the module).

Being “Passive” means that a transform does not pull from a stream, it has to be fed with data; this allows to write stream transformations (like file-formats parsing/printing) that are compatible with both “normal” I/O (like in_channel) and asynchronous libraries (like Lwt_unix or Async_unix).

Composition Functions

The TRANSFORM API provides functions to play Lego with basic Transform.t values in order to build more complex ones. Here are graphical representations of those functions:

<pre>val compose: ('a, 'b) t -> ('b, 'c) t -> ('a, 'c) t</pre> <div class="figure" style="max-width : 50%" title="Compose"> <img src="doc/figures/transform_compose.svg" width="99%"/> </div>

<pre> val mix : ('a1, 'b1) t -> ('a2, 'b2) t -> ('a1 * 'a2, [ both of 'b1 * 'b2 |left of 'b1 | `right of 'b2 ]) t </pre> <div class="figure" style="max-width : 50%" title="Mix"> <img src="doc/figures/transform_mix.svg" width="99%"/> </div>

<pre> val filter_compose: ('il, 'ol) t -> ('ir, 'our) t -> destruct:('ol -> [transform of 'ir |bypass of 'filtered]) -> reconstruct:([bypassed of 'filtered |transformed of 'our] -> 'result) -> ('il, 'result) t </pre> <div class="figure" style="max-width : 50%" title="Filter-Compose"> <img src="doc/figures/transform_filter_compose.svg" width="99%"/> </div>

<pre> val split_and_merge: ('il, 'ol) t -> ('ir, 'our) t -> split:('input -> [left of 'il |right of 'ir]) -> merge:([left of 'ol |right of 'our] -> 'output) -> ('input, 'output) t </pre> <div class="figure" style="max-width : 50%" title="Split and Merge"> <img src="doc/figures/transform_split_merge.svg" width="99%"/> </div>

<pre> val compose_results: on_error:([left of 'error_left |right of 'error_right ] -> 'error) -> ( 'input_left, ('middle, 'error_left) result) t -> ( 'middle, ('output_right, 'error_right) result) t -> ( 'input_left, ('output_right, 'error) result) t </pre> <div class="figure" style="max-width : 50%" title="Compose results"> <img src="doc/figures/transform_compose_results.svg" width="99%"/> </div>

<pre> val compose_result_left: ('input_left, ('middle, 'error) result) t -> ('middle, 'output_right) t -> ('input_left, ('output_right, 'error) result) t </pre> <div class="figure" style="max-width : 50%" title="Compose results on the left"> <img src="doc/figures/transform_compose_result_left.svg" width="99%"/> </div>

Recent activity

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.