Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax return types of Eio.Process.Pipe #775

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib_eio/process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ->
Expand Down
2 changes: 1 addition & 1 deletion lib_eio/process.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion lib_eio/unix/eio_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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. *)
Expand Down