From 3ff5c34126dd0be51afcad30fbdba28cc8f2740f Mon Sep 17 00:00:00 2001 From: Arogbonlo Date: Mon, 28 Oct 2024 21:11:00 +0100 Subject: [PATCH 1/2] relaxed return type --- lib_eio/process.ml | 5 ++++- lib_eio/process.mli | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib_eio/process.ml b/lib_eio/process.ml index 587db13a4..0cca7157f 100644 --- a/lib_eio/process.ml +++ b/lib_eio/process.ml @@ -143,7 +143,10 @@ let run t ?cwd ?stdin ?stdout ?stderr ?(is_success = Int.equal 0) ?env ?executab let pipe (type tag) ~sw ((Resource.T (v, ops)) : [> tag mgr_ty] r) = let module X = (val (Resource.get ops Pi.Mgr)) in - X.pipe v ~sw + let r, w = X.pipe v ~sw in + let r = (r : [Flow.source_ty | Resource.close_ty] r :> [< Flow.source_ty | Resource.close_ty] r) in + let w = (w : [Flow.sink_ty | Resource.close_ty] r :> [< Flow.sink_ty | Resource.close_ty] r) in + r, w let parse_out (type tag) (t : [> tag mgr_ty] r) parse ?cwd ?stdin ?stderr ?is_success ?env ?executable args = Switch.run ~name:"Process.parse_out" @@ fun sw -> diff --git a/lib_eio/process.mli b/lib_eio/process.mli index 5966bbd8f..fb19ac640 100644 --- a/lib_eio/process.mli +++ b/lib_eio/process.mli @@ -140,7 +140,7 @@ val parse_out : (** {2 Pipes} *) -val pipe : sw:Switch.t -> _ mgr -> [Flow.source_ty | Resource.close_ty] r * [Flow.sink_ty | Resource.close_ty] r +val pipe : sw:Switch.t -> _ mgr -> [< Flow.source_ty | Resource.close_ty] r * [< Flow.sink_ty | Resource.close_ty] r (** [pipe ~sw mgr] creates a pipe backed by the OS. The flows can be used by {!spawn} without the need for extra fibers to copy the data. From 08cef9c595c89cd6f48cef90504da02bf4b79e9a Mon Sep 17 00:00:00 2001 From: Arogbonlo Date: Sun, 10 Nov 2024 22:46:12 +0100 Subject: [PATCH 2/2] relaxed return types --- lib_eio/unix/eio_unix.mli | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib_eio/unix/eio_unix.mli b/lib_eio/unix/eio_unix.mli index 774ba5f6b..1b94254c1 100644 --- a/lib_eio/unix/eio_unix.mli +++ b/lib_eio/unix/eio_unix.mli @@ -58,7 +58,7 @@ val run_in_systhread : ?label:string -> (unit -> 'a) -> 'a @param label The operation name to use in trace output. *) -val pipe : Switch.t -> source_ty r * sink_ty r +val pipe : Switch.t -> [< source_ty] r * [< sink_ty] r (** [pipe sw] returns a connected pair of flows [src] and [sink]. Data written to [sink] can be read from [src]. Note that, like all FDs created by Eio, they are both marked as close-on-exec by default. *)