The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #744 from talex5/unix-net-types

Eio_unix.Net: make some return types more polymorphic

authored by

Thomas Leonard and committed by
GitHub
da087cb8 4d77de9c

+10 -9
+5 -4
vendor/opam/eio/lib_eio/unix/net.ml
··· 68 68 | Socketpair_datagram : Switch.t * Unix.socket_domain * int -> 69 69 ([`Unix_fd | datagram_socket_ty] r * [`Unix_fd | datagram_socket_ty] r) Effect.t 70 70 71 - let open_stream s = (s : _ stream_socket :> [< `Unix_fd | stream_socket_ty] r) 72 - let open_listening s = (s : _ listening_socket :> [< `Unix_fd | listening_socket_ty] r) 73 - let open_datagram s = (s : _ datagram_socket :> [< `Unix_fd | datagram_socket_ty] r) 71 + let open_stream s = (s : [`Unix_fd | stream_socket_ty] r :> [< `Unix_fd | stream_socket_ty] r) 72 + let open_listening s = (s : [`Unix_fd | listening_socket_ty] r :> [< `Unix_fd | listening_socket_ty] r) 73 + let open_datagram s = (s : [`Unix_fd | datagram_socket_ty] r :> [< `Unix_fd | datagram_socket_ty] r) 74 74 75 75 let import_socket_stream ~sw ~close_unix fd = 76 76 open_stream @@ Effect.perform (Import_socket_stream (sw, close_unix, fd)) ··· 86 86 (open_stream a, open_stream b) 87 87 88 88 let socketpair_datagram ~sw ?(domain=Unix.PF_UNIX) ?(protocol=0) () = 89 - Effect.perform (Socketpair_datagram (sw, domain, protocol)) 89 + let a, b = Effect.perform (Socketpair_datagram (sw, domain, protocol)) in 90 + (open_datagram a, open_datagram b) 90 91 91 92 let fd socket = 92 93 Option.get (Resource.fd_opt socket)
+5 -5
vendor/opam/eio/lib_eio/unix/net.mli
··· 55 55 56 56 (** {2 Creating or importing sockets} *) 57 57 58 - val import_socket_stream : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> [`Unix_fd | stream_socket_ty] r 58 + val import_socket_stream : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> [< `Unix_fd | stream_socket_ty] r 59 59 (** [import_socket_stream ~sw ~close_unix fd] is an Eio flow that uses [fd]. 60 60 61 61 It can be cast to e.g. {!source} for a one-way flow. ··· 63 63 64 64 The [close_unix] and [sw] arguments are passed to {!Fd.of_unix}. *) 65 65 66 - val import_socket_listening : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> [`Unix_fd | listening_socket_ty] r 66 + val import_socket_listening : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> [< `Unix_fd | listening_socket_ty] r 67 67 (** [import_socket_listening ~sw ~close_unix fd] is an Eio listening socket that uses [fd]. 68 68 69 69 The socket object will be closed when [sw] finishes. 70 70 71 71 The [close_unix] and [sw] arguments are passed to {!Fd.of_unix}. *) 72 72 73 - val import_socket_datagram : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> [`Unix_fd | datagram_socket_ty] r 73 + val import_socket_datagram : sw:Switch.t -> close_unix:bool -> Unix.file_descr -> [< `Unix_fd | datagram_socket_ty] r 74 74 (** [import_socket_datagram ~sw ~close_unix fd] is an Eio datagram socket that uses [fd]. 75 75 76 76 The socket object will be closed when [sw] finishes. ··· 82 82 ?domain:Unix.socket_domain -> 83 83 ?protocol:int -> 84 84 unit -> 85 - [`Unix_fd | stream_socket_ty] r * [`Unix_fd | stream_socket_ty] r 85 + [< `Unix_fd | stream_socket_ty] r * [< `Unix_fd | stream_socket_ty] r 86 86 (** [socketpair_stream ~sw ()] returns a connected pair of flows, such that writes to one can be read by the other. 87 87 88 88 This creates OS-level resources using [socketpair(2)]. ··· 93 93 ?domain:Unix.socket_domain -> 94 94 ?protocol:int -> 95 95 unit -> 96 - [`Unix_fd | datagram_socket_ty] r * [`Unix_fd | datagram_socket_ty] r 96 + [< `Unix_fd | datagram_socket_ty] r * [< `Unix_fd | datagram_socket_ty] r 97 97 (** [socketpair_datagram ~sw ()] returns a connected pair of flows, such that writes to one can be read by the other. 98 98 99 99 This creates OS-level resources using [socketpair(2)].