Skip to content

Commit

Permalink
relaxed the return types
Browse files Browse the repository at this point in the history
  • Loading branch information
Arogbonlo committed Oct 18, 2024
1 parent daad30e commit 26f17db
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
7 changes: 4 additions & 3 deletions lib_eio/process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ module Pi = struct

module type MGR = sig
type tag
type t
type t

val pipe :
t ->
sw:Switch.t ->
[< `Flow_source | `Resource_close] r * [< `Flow_sink | `Resource_close] r
[< Flow.source_ty | Resource.close_ty] r * [< Flow.sink_ty | Resource.close_ty] r

val spawn :
t ->
Expand Down Expand Up @@ -141,7 +141,8 @@ let run t ?cwd ?stdin ?stdout ?stderr ?(is_success = Int.equal 0) ?env ?executab
let ex = err (Child_error status) in
raise (Exn.add_context ex "running command: %a" pp_args args)

let pipe (type tag) ~sw ((Resource.T (v, ops)) : [> tag mgr_ty] r) =
let pipe (type tag) ~sw ((Resource.T (v, ops)) : [> tag mgr_ty] r) :
([< Flow.source_ty | Resource.close_ty ] r * [< Flow.sink_ty | Resource.close_ty ] r) =
let module X = (val (Resource.get ops Pi.Mgr)) in
X.pipe v ~sw

Expand Down
8 changes: 4 additions & 4 deletions lib_eio/process.mli
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ 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
6 changes: 2 additions & 4 deletions lib_eio/unix/eio_unix.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +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 ->
[< Flow.source_ty | Resource.close_ty] r * [< Flow.sink_ty | Resource.close_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 Expand Up @@ -99,7 +97,7 @@ module Private : sig
| Await_readable : Unix.file_descr -> unit Effect.t (** See {!await_readable} *)
| Await_writable : Unix.file_descr -> unit Effect.t (** See {!await_writable} *)
| Get_monotonic_clock : Eio.Time.Mono.ty r Effect.t
| Pipe : Eio.Switch.t -> (source_ty r * sink_ty r) Effect.t (** See {!pipe} *)
| Pipe : Eio.Switch.t -> ([< source_ty] r * [< sink_ty] r) Effect.t

module Rcfd = Rcfd

Expand Down
2 changes: 1 addition & 1 deletion lib_eio/unix/private.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type _ Effect.t +=
| Await_readable : Unix.file_descr -> unit Effect.t
| Await_writable : Unix.file_descr -> unit Effect.t
| Get_monotonic_clock : Eio.Time.Mono.ty r Effect.t
| Pipe : Switch.t -> ([< Flow.source_ty | Resource.close_ty] r * [< Flow.sink_ty | Resource.close_ty] r) Effect.t
| Pipe : Switch.t -> ([< source_ty] r * [< sink_ty] r) Effect.t

let await_readable fd = Effect.perform (Await_readable fd)
let await_writable fd = Effect.perform (Await_writable fd)
Expand Down
5 changes: 2 additions & 3 deletions lib_eio/unix/process.ml
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,8 @@ end) = struct
type tag = [ `Generic | `Unix ]

let pipe _ ~sw =
(Eio.Process.pipe ~sw :> ([< Eio.Resource.close_ty | Eio.Flow.source_ty] r *
[< Eio.Resource.close_ty | Eio.Flow.sink_ty] r))

(Private.pipe sw :> ([< Eio.Resource.close_ty | Eio.Flow.source_ty] r *
[< Eio.Resource.close_ty | Eio.Flow.sink_ty] r))

let spawn v ~sw ?cwd ?stdin ?stdout ?stderr ?env ?executable args =
let executable = get_executable executable ~args in
Expand Down
4 changes: 2 additions & 2 deletions lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,8 @@ let run_event_loop (type a) ?fallback config (main : _ -> a) arg : a =
| Eio_unix.Private.Pipe sw -> Some (fun k ->
match
let r, w = Low_level.pipe ~sw in
let r = (Flow.of_fd r :> _ Eio_unix.source) in
let w = (Flow.of_fd w :> _ Eio_unix.sink) in
let r = (Flow.of_fd r :> [< Eio_unix.source_ty] Eio.Std.r) in
let w = (Flow.of_fd w :> [< Eio_unix.sink_ty] Eio.Std.r) in
(r, w)
with
| r -> continue k r
Expand Down

0 comments on commit 26f17db

Please sign in to comment.