-
Using Lwt_ppx Rewriter
2020-06-21
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. https://ocsigen.org/lwt/5.2.0/api/Ppx_lwt 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:…
-
Playing With Cohttp and Yojson
2020-06-21
Playing with Cohttp and Yojson Few days ago I needed to parse a json file. This file can be found in a github repository. The idea is to try to download the very last version, if the download fails, a local copy is used. The libraries Cohttp It is an OCaml library for HTTP clients and servers using Lwt and Async https://github.com/mirage/ocaml-cohttp Yojson It is a Low-level JSON parsing and pretty-printing library for OCaml…