Source file Types.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29

type 'a source =
  Source : {
    init : unit -> 's;
    pull : 's -> ('a * 's) option;
    stop : 's -> unit;
  } -> 'a source


type ('a, 'b) sink =
  Sink : { 
    init : unit -> 's;
    push : 's -> 'a -> 's;
    (* Could be potentially extended to support finer grained back pressure
     * control. Instead of a bool we could use [`full | `more | `wait]. *)
    full : 's -> bool;
    stop : 's -> 'b;
  } -> ('a, 'b) sink


type 'a stream =
  { stream : 'b . ('a, 'b) sink -> 'b }
  [@@unboxed]


type ('a, 'b) flow =
  { flow : 'r . ('b, 'r) sink -> ('a, 'r) sink }
  [@@unboxed]