Open Arogbonlo opened 3 weeks ago
Hey @talex5 @patricoferris . I'm sure this is better. Please check it out and let me know. Thank you.
Thanks @Arogbonlo !
I appreciate your efforts!
Ok. I'll get that done immediately!
Hey @talex5 @patricoferris . I'm sure this is better. Please check it out and let me know. Thank you.
Hello @talex5 ,
Each time i update eio_unix.mli
with the more flexible types, the build constantly fails. Please I'd like your intervention here. Thank you
In the eio_unix.mli
file, there is
val pipe : Switch.t -> source_ty r * sink_ty r
, which returns a pair of flows (source_ty r
and sink_ty r
), where source_ty
and sink_ty
are defined as:
type source_ty = [`Unix_fd | Eio.Resource.close_ty | Eio.Flow.source_ty]
type sink_ty = [`Unix_fd | Eio.Resource.close_ty | Eio.Flow.sink_ty]
This union typing ([Unix_fd | Eio.Resource.close_ty | Eio.Flow.source_ty]forsource_ty) makes pipe’s output flexible enough to match what’s required in process.mli
.
In process.mli
, the pipe function has a similar signature :
val pipe : sw:Switch.t -> _ mgr -> [< Flow.source_ty | Resource.close_ty] r * [< Flow.sink_ty | Resource.close_ty] r
So @talex5 , I think flexibility in eio_unix.mli
ensures that the flows returned by pipe can match the input requirements of functions in process.mli
.
The one in process.mli
now uses <
. The one in eio_unix.mli
doesn't. This is what you were trying change.
utop # Eio_main.run (fun _ -> Eio.Switch.run (fun sw -> let (r : Eio.Flow.source_ty Eio.Resource.t), _ = Eio_unix.pipe sw in ()));;
Error: This expression has type
Eio_unix.source_ty Eio_unix.source * Eio_unix.sink_ty Eio_unix.source
but an expression was expected of type
Eio.Flow.source_ty Eio_unix.source * 'a
Type Eio_unix.source_ty = [ `Close | `Flow | `R | `Unix_fd ]
is not compatible with type Eio.Flow.source_ty = [ `Flow | `R ]
The second variant type does not allow tag(s) `Close, `Unix_fd
The one in
process.mli
now uses<
. The one ineio_unix.mli
doesn't. This is what you were trying change.utop # Eio_main.run (fun _ -> Eio.Switch.run (fun sw -> let (r : Eio.Flow.source_ty Eio.Resource.t), _ = Eio_unix.pipe sw in ()));; Error: This expression has type Eio_unix.source_ty Eio_unix.source * Eio_unix.sink_ty Eio_unix.source but an expression was expected of type Eio.Flow.source_ty Eio_unix.source * 'a Type Eio_unix.source_ty = [ `Close | `Flow | `R | `Unix_fd ] is not compatible with type Eio.Flow.source_ty = [ `Flow | `R ] The second variant type does not allow tag(s) `Close, `Unix_fd
I just resolved that. I just uploaded the pipe
function signature in eio_unix.mli
But after doing that, the build constantly fails.
This PR relaxes the return types of the pipe function in Eio.Process to make the code more flexible. The main goal was to allow the pipe function to handle a broader range of types for input and output flows, while still maintaining compatibility with the rest of the codebase.
Changes:
Relaxed Type Definitions: I’ve updated the return types for pipe so they can accept any subtype of
Flow.source_ty
andFlow.sink_ty
. This will give us more flexibility when working with processes that require different types of flows.Polymorphic Variants: I used polymorphic variants (
[< .. ]
) to allow for more flexible types, ensuring that the code still works with the broader variants expected in other parts of the system.Testing: I ran dune runtest and confirmed that all tests are passing with these changes. The new types work fine, and the tests ensure everything is still functioning as expected.
This addresses issue https://github.com/ocaml-multicore/eio/issues/750, improving flexibility when working with various APIs that use stricter type definitions for sources and sinks.