Version 1.2.0
This is a preliminary version of the documentation. Help us to improve it by filling tickets. We are looking for native english speakers to proof read the documentation. Contact us!
module Pa_lwt:Syntactic sugars for lwtsig..end
put_string stdio "Hello, " >> put_string stdio "world!" >> x := 1; sleep 1.0 >> return 1 lwt ch = get_char stdin in code is the same as bind (get_char stdin) (fun ch -> code)
Moreover it supports parallel binding:
lwt x = do_something1 () and y = do_something2 in code will let do_something1 () and do_something2 () runs then bind their result to x and y. It is the same as:
let t1 = do_something1 and t2 = do_something2 in bind t1 (fun x -> bind t2 (fun y -> code)) try_lwt <expr> ,
try_lwt <expr> with <branches> ,
try_lwt <expr> finally <expr> and:
try_lwt <expr> with <branches> finally <expr> For example:
try_lwt f x with | Failure msg -> prerr_endline msg; return () is expanded to:
catch (fun _ -> f x) (function | Failure msg -> prerr_endline msg; return () | exn -> Lwt.fail exn) Note that the exn -> Lwt.fail exn branch is automatically addedd when needed.
The construction try_lwt <expr> just catch regular exception into lwt exception. i.e. it is the same as catch (fun _ -> <expr>) fail.
for_lwt i = <expr> to <expr> do <expr> done and:
for_lwt i = <expr> downto <expr> do <expr> done for_lwt <patt> in <expr> do <expr> done