-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
7 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
let () = | ||
set_binary_mode_out stdout true; | ||
let ic = open_in_bin "ic.ml" in | ||
[%defer close_in ic]; | ||
let length = in_channel_length ic in | ||
let bytes = really_input_string ic length in | ||
print_endline bytes | ||
|
||
print_string bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
let () = | ||
set_binary_mode_out stdout true; | ||
let ic = open_in_bin "ic.ml" in | ||
[%defer close_in ic]; | ||
let length = in_channel_length ic in | ||
let bytes = really_input_string ic length in | ||
print_endline bytes | ||
print_string bytes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1 @@ | ||
let promise = | ||
let%lwt ic = Lwt_io.open_file ~mode:Lwt_io.input "ic_lwt.ml" in | ||
[%defer.lwt Lwt_io.close ic]; | ||
let%lwt bytes = Lwt_io.read ic in | ||
Lwt_io.printl bytes | ||
|
||
let () = Lwt_main.run promise | ||
|
||
Hello world |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
let promise = | ||
let%lwt ic = Lwt_io.open_file ~mode:Lwt_io.input "ic_lwt.ml" in | ||
[%defer.lwt Lwt_io.close ic]; | ||
let%lwt bytes = Lwt_io.read ic in | ||
Lwt_io.printl bytes | ||
[%defer.lwt Lwt_io.write Lwt_io.stdout " world"]; | ||
Lwt_io.write Lwt_io.stdout "Hello" | ||
|
||
let () = Lwt_main.run promise |