Skip to content

Instantly share code, notes, and snippets.

@ehirdoy
Created February 1, 2019 08:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehirdoy/e1ed3893d37ed5a62b6b429bd1370df1 to your computer and use it in GitHub Desktop.
Save ehirdoy/e1ed3893d37ed5a62b6b429bd1370df1 to your computer and use it in GitHub Desktop.
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 ())
@ehirdoy
Copy link
Author

ehirdoy commented Feb 1, 2019

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 ())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment