Use Lwt_ppx in a dune project
Lwt_ppx offers a syntax for Lwt that is the equivalent to async/await for JavaScript syntax.
The documentation is good but it doesn’t describes how to use this syntax in a dune project.
In your dune file just add the following line:
(preprocess (pps lwt_ppx))
This line tells dune to preprocess the code code with an AST rewriter that knows how to transform Lwt promises written like this:
let%lwt ch = get_char string in
code ...
For example:
(library
(name mylib)
(public_name mylib)
(libraries lwt cohttp cohttp-lwt cohttp-lwt-unix yojson lwt_ppx)
(preprocess (pps lwt_ppx))
)