Created
February 1, 2019 08:59
-
-
Save ehirdoy/e1ed3893d37ed5a62b6b429bd1370df1 to your computer and use it in GitHub Desktop.
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
open Lwt.Infix | |
let mysleep delay : unit Lwt.t = | |
print_endline "Sleeping"; | |
Lwt_unix.sleep delay >|= | |
fun () -> print_endline "Waked up???" | |
let main () : unit Lwt.t = | |
mysleep 3. | |
let () = | |
Lwt_main.run (main ()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I want to change the above code to the following, mysleep () returns unit instead of the original unit Lwt.t but the following code doesn't work(doesn't sleep)...what should I do?
open Lwt.Infix
let mysleep delay : unit =
print_endline "Sleeping";
(Lwt_unix.sleep delay >|=
fun () -> print_endline "Waked up???") |> ignore
let main () : unit Lwt.t =
mysleep 3.;
Lwt.return_unit
let () =
Lwt_main.run (main ())