Skip to content

Commit 7198c32

Browse files
committed
Translate 'Lwt_unix.read_value' and 'write_value'
They are translated to corresponding blocking calls to Marshal. This will most probably not type check as other IO functions are working on either `Eio.Flow` or `Eio.Buf_read`.
1 parent fb23848 commit 7198c32

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

bin/lwt_to_direct_style/ast_rewrite.ml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ let rewrite_apply ~backend ~state full_ident args =
318318
(( "socket" | "socketpair" | "listen" | "shutdown" | "getsockname"
319319
| "getpeername" | "waitpid" | "wait4" | "wait" ) as ident) ) ->
320320
transparent [ "Unix"; ident ]
321+
| "Lwt_io", "read_value" -> transparent [ "Marshal"; "from_channel" ]
322+
| "Lwt_io", "write_value" -> transparent [ "Marshal"; "to_channel" ]
321323
| "Lwt_unix", (("connect" | "accept" | "bind") as ident) ->
322324
Printf.ksprintf (add_comment state)
323325
"This call to [Unix.%s] was [Lwt_unix.%s] before. It's now blocking."

test/lwt_to_direct_style/to_direct_style.t/run.t

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ Make a writable directory tree:
230230
Lwt_mutex.lock (line 136 column 9)
231231
Lwt_mutex.unlock (line 137 column 9)
232232
Lwt_mutex.with_lock (line 138 column 9)
233-
lib/test_lwt_unix.ml: (53 occurrences)
233+
lib/test_lwt_unix.ml: (55 occurrences)
234234
Lwt_io (line 7 column 8)
235235
Lwt.return (line 12 column 3)
236236
Lwt.return (line 46 column 11)
@@ -259,8 +259,10 @@ Make a writable directory tree:
259259
Lwt_io.read (line 41 column 15)
260260
Lwt_io.read_into (line 10 column 21)
261261
Lwt_io.read_into_exactly (line 11 column 13)
262+
Lwt_io.read_value (line 57 column 12)
262263
Lwt_io.flush (line 42 column 15)
263264
Lwt_io.write (line 24 column 19)
265+
Lwt_io.write_value (line 58 column 14)
264266
Lwt_io.length (line 35 column 3)
265267
Lwt_io.stdin (line 25 column 32)
266268
Lwt_io.stdout (line 26 column 33)
@@ -861,3 +863,5 @@ Make a writable directory tree:
861863
a b
862864

863865
let _f a b = Unix.listen a b
866+
let _f a = Marshal.from_channel a
867+
let _f a b = Marshal.to_channel a b

test/lwt_to_direct_style/to_direct_style.t/src/lib/test_lwt_unix.ml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ let _f a b = Lwt_unix.connect a b
5353
let _f a = Lwt_unix.accept a
5454
let _f a b = Lwt_unix.bind a b
5555
let _f a b = Lwt_unix.listen a b
56+
57+
let _f a = Lwt_io.read_value a
58+
let _f a b = Lwt_io.write_value a b

0 commit comments

Comments
 (0)