HMJFS6WWD2JJZB57HBXRHYS2A2N25YDDAJ443KRMT6K3ALHIBRVQC let cli_fmter = Relog.Formatter.default ~color:true ~oneline:false () inlet cli_fmt = Format.std_formatter inRelog.Sink.make (fun r ->if Relog.(Level.compare (Record.level r) Level.Debug) <= 0 thencli_fmter cli_fmt relse ())
let open Relog inlet cli_fmter = Formatter.default ~color:true ~oneline:false () inlet cli_fmt = Format.formatter_of_out_channel stderr inSink.make (fun r ->if Level.Infix.(Record.level r <= Debug) then cli_fmter cli_fmt r else ())
module Mpmc = Dp_utils.Mpmclet () =let source, sink = Mpmc.create () inlet sink2 = Mpmc.Sink.(clone sink |> map ~f:(fun i -> i * 2)) inlet _cancel =Mpmc.Sink.iter sink2 ~f:(function| Some v -> Printf.printf "(sink 2) %d\n%!" v| None -> Printf.printf "(sink 2) dropped\n%!")inlet _cancel =Mpmc.Sink.iter sink ~f:(function| Some v -> Printf.printf "(sink 1) %d\n%!" v| None -> Printf.printf "(sink 1) dropped\n%!")inSeq.(1 -- 10 |> iter (fun v -> Mpmc.Source.write source v |> ignore));Seq.(1 -- 5 |> iter (fun v -> Mpmc.Source.write source v |> ignore));Mpmc.Source.close source
"ocaml@4.11.2000@d41d8cd9", "@reason-native/pastel@0.3.0@d41d8cd9","@opam/yojson@opam:1.7.0@7056d985","@opam/ptime@opam:0.8.5@0051d642", "@opam/dune@opam:2.8.4@ee414d6c","@opam/containers@opam:3.2@c4e3f662","@esy-ocaml/reason@3.7.0@d41d8cd9"
"ocaml@4.11.2000@d41d8cd9", "@opam/yojson@opam:1.7.0@7056d985","@opam/reason@opam:3.7.0@191be014","@opam/ptime@opam:0.8.5@0051d642", "@opam/dune@opam:2.8.4@1490e2a1","@opam/containers@opam:3.2@c4e3f662"
},"@reason-native/pastel@0.3.0@d41d8cd9": {"id": "@reason-native/pastel@0.3.0@d41d8cd9","name": "@reason-native/pastel","version": "0.3.0","source": {"type": "install","source": ["archive:https://registry.npmjs.org/@reason-native/pastel/-/pastel-0.3.0.tgz#sha1:07da3c5a0933e61bc3b353bc85aa71ac7c0f311c"]},"overrides": [],"dependencies": ["ocaml@4.11.2000@d41d8cd9", "@opam/re@opam:1.9.0@d4d5e13d","@opam/dune@opam:2.8.4@ee414d6c", "@esy-ocaml/reason@3.7.0@d41d8cd9"],"devDependencies": []
"ocaml@4.11.2000@d41d8cd9", "@opam/dune@opam:2.8.4@ee414d6c",
"ocaml@4.11.2000@d41d8cd9", "@opam/dune@opam:2.8.4@1490e2a1","@esy-ocaml/substs@0.0.1@d41d8cd9"],"devDependencies": ["ocaml@4.11.2000@d41d8cd9", "@opam/dune@opam:2.8.4@1490e2a1"]},"@opam/reason@opam:3.7.0@191be014": {"id": "@opam/reason@opam:3.7.0@191be014","name": "@opam/reason","version": "opam:3.7.0","source": {"type": "install","source": ["archive:https://opam.ocaml.org/cache/md5/7e/7eb8cbbff8565b93ebfabf4eca7254d4#md5:7eb8cbbff8565b93ebfabf4eca7254d4","archive:https://registry.npmjs.org/@esy-ocaml/reason/-/reason-3.7.0.tgz#md5:7eb8cbbff8565b93ebfabf4eca7254d4"],"opam": {"name": "reason","version": "3.7.0","path": "esy.lock/opam/reason.3.7.0"}},"overrides": [],"dependencies": ["ocaml@4.11.2000@d41d8cd9", "@opam/result@opam:1.5@6b753c82","@opam/ppx_derivers@opam:1.2.1@ecf0aa45","@opam/ocamlfind@opam:1.8.1@b7dc3072","@opam/merlin-extend@opam:0.6@404f814c","@opam/menhir@opam:20210310@50de9216","@opam/fix@opam:20201120@5c318621", "@opam/dune@opam:2.8.4@1490e2a1",
"ocaml@4.11.2000@d41d8cd9", "@opam/dune@opam:2.8.4@ee414d6c"
"ocaml@4.11.2000@d41d8cd9", "@opam/result@opam:1.5@6b753c82","@opam/ppx_derivers@opam:1.2.1@ecf0aa45","@opam/merlin-extend@opam:0.6@404f814c","@opam/menhir@opam:20210310@50de9216","@opam/fix@opam:20201120@5c318621", "@opam/dune@opam:2.8.4@1490e2a1"
"archive:https://opam.ocaml.org/cache/sha256/4e/4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac#sha256:4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac","archive:https://github.com/ocaml/dune/releases/download/2.8.4/dune-2.8.4.tbz#sha256:4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac"
"archive:https://opam.ocaml.org/cache/sha256/79/79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629#sha256:79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629","archive:https://github.com/ocaml/dune/releases/download/2.8.5/dune-2.8.5.tbz#sha256:79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629"
"archive:https://opam.ocaml.org/cache/sha256/4e/4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac#sha256:4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac","archive:https://github.com/ocaml/dune/releases/download/2.8.4/dune-2.8.4.tbz#sha256:4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac"
"archive:https://opam.ocaml.org/cache/sha256/79/79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629#sha256:79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629","archive:https://github.com/ocaml/dune/releases/download/2.8.5/dune-2.8.5.tbz#sha256:79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629"
"@esy-ocaml/reason@3.7.0@d41d8cd9": {"id": "@esy-ocaml/reason@3.7.0@d41d8cd9","name": "@esy-ocaml/reason","version": "3.7.0","source": {"type": "install","source": ["archive:https://registry.npmjs.org/@esy-ocaml/reason/-/reason-3.7.0.tgz#sha1:36f92c1c854477c4da37e4769a045ffe60e4fb10"]},"overrides": [],"dependencies": ["ocaml@4.11.2000@d41d8cd9", "@opam/result@opam:1.5@6b753c82","@opam/ppx_derivers@opam:1.2.1@ecf0aa45","@opam/ocamlfind@opam:1.8.1@b7dc3072","@opam/merlin-extend@opam:0.6@404f814c","@opam/menhir@opam:20210310@50de9216","@opam/fix@opam:20201120@5c318621", "@opam/dune@opam:2.8.4@ee414d6c"],"devDependencies": []},
"sha256=4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac""sha512=efc1834c4add40138a101734665a1f462c19fe76d1cbb457b1fc20f95991118a50b24d485fb98d39046e41bec03885a8dc071bf8add51083ac9780bff9f6668a"
"sha256=79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629""sha512=4ef6cdea0768a29de0108cb61b04ef471cb494762c865265f20d7d15ed65a39557f7e34f2dbd466352a6567cce29d7ba21be6569afafbcfc2871720b9466dcae"
"sha256=4e6420177584aabdc3b7b37aee3026b094b82bf5d7ed175344a68e321f72e8ac""sha512=efc1834c4add40138a101734665a1f462c19fe76d1cbb457b1fc20f95991118a50b24d485fb98d39046e41bec03885a8dc071bf8add51083ac9780bff9f6668a"
"sha256=79011283fb74c7a27eb17ad752efbcc39b39633cbacc8d7be97e8ea869443629""sha512=4ef6cdea0768a29de0108cb61b04ef471cb494762c865265f20d7d15ed65a39557f7e34f2dbd466352a6567cce29d7ba21be6569afafbcfc2871720b9466dcae"
opam-version: "2.0"maintainer: "Jordan Walke <jordojw@gmail.com>"authors: [ "Jordan Walke <jordojw@gmail.com>" ]license: "MIT"homepage: "https://github.com/facebook/reason"doc: "http://reasonml.github.io/"bug-reports: "https://github.com/facebook/reason/issues"dev-repo: "git://github.com/facebook/reason.git"tags: [ "syntax" ]build: [["dune" "build" "-p" name "-j" jobs]]depends: ["ocaml" {>= "4.03" & < "4.13"}"dune" {>= "1.4"}"ocamlfind" {build}"menhir" {>= "20170418"}"merlin-extend" {>= "0.6"}"ppx_derivers" {< "2.0"}"fix""result"]synopsis: "Reason: Syntax & Toolchain for OCaml"description: """Reason gives OCaml a new syntax that is remniscient of languages likeJavaScript. It's also the umbrella project for a set of tools for the OCaml &JavaScript ecosystem."""url {src: "https://registry.npmjs.org/@esy-ocaml/reason/-/reason-3.7.0.tgz"checksum: "md5=7eb8cbbff8565b93ebfabf4eca7254d4"}
let y = yield t >|= fun () -> if t.dead then `Dead else `Yield inLwt.choose [ tick; y ] >>= function| `Dead ->
let y =match !last_yield with| Some y -> y| None ->let y = yield t inlast_yield := Some y;yinLwt.choose [ tick; (y >|= fun () -> `Yield) ] >>= function| `Yield when t.dead ->
(library(name dp_utils)(public_name discopotty.utils)(preprocess(pps ppx_deriving.show ppx_deriving.ord))(libraries containers containers-data ke stdint lwt relog.lib))
open Containerstype 'a sink = {mutable readers : 'a reader Ke.Fke.t;mutable buf : 'a Ke.Fke.t;mutable dropped : bool;clone : unit -> 'a sink;}and 'a reader = { mutable canceled : bool; dispatch : 'a option -> unit }type 'a source = { mutable sinks : 'a sink Weak.t; mutable closed : bool }let stub = Sys.opaque_identity (fun () -> ())module Sink = structtype 'a t = 'a sinklet clone t =if t.dropped then failwith "cannot clone dropped sink";let s = t.clone () ins.buf <- t.buf;slet rec make ?clone () ={readers = Ke.Fke.empty;buf = Ke.Fke.empty;dropped = false;clone = clone |> Option.get_or ~default:(fun () -> make ());}let peek t = Ke.Fke.peek t.buflet read_opt t =match Ke.Fke.pop t.buf with| Some (a, tl) ->t.buf <- tl;Some a| None -> Nonelet schedule_read t ~f =match read_opt t with| Some a ->f (Some a);stub| None when t.dropped ->f None;stub| None ->let r = { canceled = false; dispatch = f } int.readers <- Ke.Fke.push t.readers r;fun () -> if not r.canceled then r.canceled <- truelet push t v =if t.dropped then falseelselet rec f q =match Ke.Fke.pop q with| Some ({ canceled = true; _ }, tl) ->print_endline "skipping cancelled reader";f tl| Some ({ dispatch; _ }, tl) ->print_endline "waking up reader";t.readers <- tl;dispatch (Some v)| None ->print_endline "pushed to buffer";t.readers <- Ke.Fke.empty;t.buf <- Ke.Fke.push t.buf vinf t.readers;truelet drop t =if not t.dropped then (t.dropped <- true;Ke.Fke.iter(function| { canceled = true; _ } -> () | { dispatch; _ } -> dispatch None)t.readers;t.readers <- Ke.Fke.empty)let map ~f t =let o = make () inlet rec fwd = function| Some v ->if push o (f v) then schedule_read t ~f:fwd |> ignore else drop o| None -> drop oinschedule_read t ~f:fwd |> ignore;olet filter ~f t =let o = make () inlet rec fwd = function| Some v when f v ->if push o v then schedule_read t ~f:fwd |> ignore else drop o| Some _ -> schedule_read t ~f:fwd |> ignore| None -> drop oinschedule_read t ~f:fwd |> ignore;olet iter t ~f =let cancel = ref stub inlet rec iter' = function| Some v ->f (Some v);cancel := schedule_read t ~f:iter'| None -> f Noneincancel := schedule_read t ~f:iter';fun () -> !cancel ()let rec merge sinks =let ks = ref @@ ((1 lsl List.length sinks) - 1) inlet o = make ~clone:(fun () -> List.map clone sinks |> merge) () inlet c = Array.make (List.length sinks) stub inlet cancel () = Array.iter (fun c -> c ()) c inlet rec fwd i k = function| Some v ->if push o v then c.(i) <- schedule_read k ~f:(fwd i k)else (cancel ();List.iter drop sinks)| None ->ks := !ks land lnot (1 lsl i);if !ks = 0 then drop oinList.iteri (fun i k -> c.(i) <- schedule_read k ~f:(fwd i k)) sinks;omodule Lwt = structlet read t =let p, u = Lwt.task () inlet cancel = schedule_read t ~f:(Lwt.wakeup_later u) inLwt.on_cancel p cancel;plet iter_s ~f t =let open Lwt.Infix inlet rec iter () =read t >>= function Some v -> f v >>= iter | None -> Lwt.return_unitiniter ()let iter_p ~f t =let open Lwt.Infix inlet rec cleanup ?(acc = []) = function| [] -> Ok acc| p :: ps -> (match Lwt.state p with| Lwt.Fail e -> Error e| Lwt.Sleep -> cleanup ~acc:(p :: acc) ps| Lwt.Return _ -> cleanup ~acc ps)inlet rec join ?(acc = []) () =read t >>= function| None -> Lwt.join acc| Some v -> (match cleanup acc with| Ok acc -> join ~acc:(f v :: acc) ()| Error exn -> Lwt.fail exn)injoin ()endendmodule Source = structtype 'a t = 'a sourcelet sinks t =Seq.(0 --^ Weak.length t.sinks) |> Seq.filter_map (Weak.get t.sinks)let write t x =if t.closed then falseelsesinks t|> Seq.filter (fun s -> not @@ s.dropped)|> Seq.fold (fun flag s -> flag || Sink.push s x) falselet close t =t.closed <- true;sinks t |> Seq.iter Sink.dropendlet grow t =let len = Weak.length t.sinks inif Obj.Ephemeron.max_ephe_length - len < len thenfailwith "reached maximum number of sinks";let w = Weak.create (len * 2) inWeak.blit t.sinks 0 w 0 len;t.sinks <- wlet get_free_sink_ref t =let len = Weak.length t.sinks inlet rec f' ?(i = 0) w =if i >= len then Noneelsematch Weak.get w i with| None -> Some i| Some c when c.dropped -> Some i| Some _ -> f' ~i:(i + 1) winmatch f' t.sinks with| Some i -> i| None ->grow t;lenlet create () =let sinks = Weak.create 4 inlet source = { sinks; closed = false } inlet rec make_sink () =let r = get_free_sink_ref source inlet sink ={readers = Ke.Fke.empty;buf = Ke.Fke.empty;dropped = false;clone = make_sink;}inGc.finalise(fun k ->Printf.printf "gc'ing sink with %d buffered elements and %d readers\n%!"(Ke.Fke.length k.buf) (Ke.Fke.length k.readers);Sink.drop k)sink;Weak.set source.sinks r (Some sink);sinkin(source, make_sink ())