Skip to content

Commit 052436a

Browse files
committed
Translate 'Lwt_io.input_channel'
1 parent cd56116 commit 052436a

File tree

4 files changed

+26
-19
lines changed

4 files changed

+26
-19
lines changed

bin/lwt_to_direct_style/ast_rewrite.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ let rewrite_type ~backend ~state typ =
552552
| "group_entry" ) as tname) ),
553553
params ) ->
554554
Some (mk_typ_constr ~params [ "Unix"; tname ])
555+
| ("Lwt_io", "input_channel"), [] -> Some backend#type_in_channel
555556
| ("Lwt_io", "output_channel"), [] -> Some backend#type_out_channel
556557
| _ -> None)
557558
| _ -> None

bin/lwt_to_direct_style/concurrency_backend.ml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@ let eio ~eio_sw_as_fiber_var ~eio_env_as_fiber_var add_comment =
317317
mk_apply_simple [ "Eio"; "Buf_write"; "string" ] [ chan; str ]
318318

319319
method io_close fd = mk_apply_simple [ "Eio"; "Resource"; "close" ] [ fd ]
320+
method type_in_channel = mk_typ_constr [ "Eio"; "Buf_read"; "t" ]
320321
method type_out_channel = mk_typ_constr [ "Eio"; "Buf_write"; "t" ]
321322

322323
method path_stat ~follow path =

test/lwt_to_direct_style/to_direct_style.t/run.t

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -228,42 +228,44 @@ Make a writable directory tree:
228228
Lwt_mutex.lock (line 136 column 9)
229229
Lwt_mutex.unlock (line 137 column 9)
230230
Lwt_mutex.with_lock (line 138 column 9)
231-
lib/test_lwt_unix.ml: (41 occurrences)
231+
lib/test_lwt_unix.ml: (43 occurrences)
232232
Lwt_io (line 7 column 8)
233233
Lwt.return (line 12 column 3)
234234
Lwt.let* (line 10 column 3)
235235
Lwt.let* (line 11 column 3)
236-
Lwt.let* (line 29 column 3)
237-
Lwt.let* (line 33 column 3)
236+
Lwt.let* (line 30 column 3)
237+
Lwt.let* (line 34 column 3)
238238
Lwt.Syntax (line 1 column 6)
239239
Lwt_io.Input (line 22 column 32)
240240
Lwt_io.Output (line 23 column 32)
241241
Lwt_io.input (line 7 column 28)
242-
Lwt_io.input (line 29 column 36)
242+
Lwt_io.input (line 30 column 36)
243243
Lwt_io.output (line 21 column 32)
244-
Lwt_io.output (line 33 column 36)
245-
Lwt_io.output_channel (line 25 column 9)
246-
Lwt_io.close (line 30 column 3)
244+
Lwt_io.output (line 34 column 36)
245+
Lwt_io.input_channel (line 25 column 9)
246+
Lwt_io.output_channel (line 26 column 9)
247+
Lwt_io.close (line 31 column 3)
247248
Lwt_io.of_fd (line 7 column 16)
248249
Lwt_io.of_fd (line 21 column 13)
249250
Lwt_io.of_fd (line 22 column 13)
250251
Lwt_io.of_fd (line 23 column 13)
251-
Lwt_io.read_line (line 26 column 15)
252-
Lwt_io.read (line 38 column 15)
252+
Lwt_io.read_line (line 27 column 15)
253253
Lwt_io.read (line 39 column 15)
254254
Lwt_io.read (line 40 column 15)
255+
Lwt_io.read (line 41 column 15)
255256
Lwt_io.read_into (line 10 column 21)
256257
Lwt_io.read_into_exactly (line 11 column 13)
257-
Lwt_io.flush (line 41 column 15)
258+
Lwt_io.flush (line 42 column 15)
258259
Lwt_io.write (line 24 column 19)
259-
Lwt_io.length (line 34 column 3)
260-
Lwt_io.stdout (line 25 column 33)
261-
Lwt_io.open_file (line 29 column 13)
262-
Lwt_io.open_file (line 33 column 13)
260+
Lwt_io.length (line 35 column 3)
261+
Lwt_io.stdin (line 25 column 32)
262+
Lwt_io.stdout (line 26 column 33)
263+
Lwt_io.open_file (line 30 column 13)
264+
Lwt_io.open_file (line 34 column 13)
263265
Lwt_unix.Timeout (line 14 column 9)
264266
Lwt_unix.of_unix_file_descr (line 6 column 8)
265-
Lwt_unix.stat (line 36 column 16)
266-
Lwt_unix.lstat (line 37 column 16)
267+
Lwt_unix.stat (line 37 column 16)
268+
Lwt_unix.lstat (line 38 column 16)
267269
Lwt_unix.sockaddr (line 15 column 9)
268270
Lwt_unix.ADDR_UNIX (line 15 column 29)
269271
Lwt_unix.ADDR_UNIX (line 17 column 6)
@@ -300,10 +302,11 @@ Make a writable directory tree:
300302
Lwt.Fail (line 147 column 5)
301303
Lwt.let* (line 163 column 21)
302304
Lwt.Fail (line 179 column 9)
303-
Warning: lib/test_lwt_unix.ml: 3 occurrences have not been rewritten.
304-
Lwt_io.stdout (line 25 column 33)
305-
Lwt_io.read (line 39 column 15)
305+
Warning: lib/test_lwt_unix.ml: 4 occurrences have not been rewritten.
306+
Lwt_io.stdin (line 25 column 32)
307+
Lwt_io.stdout (line 26 column 33)
306308
Lwt_io.read (line 40 column 15)
309+
Lwt_io.read (line 41 column 15)
307310
Warning: lib/test.mli: 2 occurrences have not been rewritten.
308311
Lwt_mutex.t (line 2 column 10)
309312
Lwt_mutex.t (line 3 column 10)
@@ -749,6 +752,7 @@ Make a writable directory tree:
749752
(fun outbuf -> `Move_writing_code_here)
750753
751754
let _f out_chan = Eio.Buf_write.string out_chan "str"
755+
let _ : Eio.Buf_read.t = Lwt_io.stdin
752756
let _ : Eio.Buf_write.t = Lwt_io.stdout
753757
let _f chan = Eio.Buf_read.line chan
754758

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let _f fd = Lwt_io.of_fd ~mode:Lwt_io.output fd
2222
let _f fd = Lwt_io.of_fd ~mode:Lwt_io.Input fd
2323
let _f fd = Lwt_io.of_fd ~mode:Lwt_io.Output fd
2424
let _f out_chan = Lwt_io.write out_chan "str"
25+
let _ : Lwt_io.input_channel = Lwt_io.stdin
2526
let _ : Lwt_io.output_channel = Lwt_io.stdout
2627
let _f chan = Lwt_io.read_line chan
2728

0 commit comments

Comments
 (0)