-
-
Save superherointj/eac826dac431719d1e2b08eb6443c8c5 to your computer and use it in GitHub Desktop.
LWT demo - SYNC vs ASYNC printing
This file contains hidden or 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
(executable | |
(name lwt_demo1) | |
(libraries lwt lwt.unix) | |
(preprocess (pps lwt_ppx)) | |
(flags (:standard -warn-error -22)) | |
) |
This file contains hidden or 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
(* | |
Is Printf.printft SYNC? But... | |
*) | |
let () = Printf.printf "=== This line is printed last. Why?\n";; | |
(* Awaits the user to type something and then prints it. *) | |
let () = | |
Lwt_main.run begin | |
let%lwt data = Lwt_io.(read_line stdin) in | |
let%lwt () = Lwt_io.printl data in | |
Lwt.return () | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment