Skip to content

Instantly share code, notes, and snippets.

@xguerin
Created January 25, 2020 03:21
Show Gist options
  • Save xguerin/158056a6fd3cd0a19c404b44eeb28355 to your computer and use it in GitHub Desktop.
Save xguerin/158056a6fd3cd0a19c404b44eeb28355 to your computer and use it in GitHub Desktop.
let beacon =
new beacon ~zero:(fun() -> 0) ~next:(fun v -> v + 1)
let apply_fn (v0, v1) =
Logs_lwt.info (fun m -> m "(%d, %d)" v0 v1)
>>= fun () -> Lwt.return (v0, v1)
let () =
Logs.set_reporter (Logs.format_reporter ());
Logs.set_level (Some Logs.Info);
(* Streams *)
[%fstream
(Vertex("B0", beacon) +> Vertex("B1", beacon))
*>
Vertex("M0", new merge)
+>
Vertex("M0", ())
*>
Vertex("A0", new apply ~fn:apply_fn)
+>
Vertex("A0", ())
*>
Vertex("S0", new sink)
]
|> List.map(fun e -> e#process)
|> Lwt.join
|> Lwt_main.run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment