I'm trying to make this piece of code:
open Lwt;;
open Cohttp;;
(* a simple function to access the content of the response *)
let content = function
| Some (_, body) -> Cohttp_lwt_unix.Body.string_of_body body
(* launch both requests in parallel *)
let t = Lwt_list.map_p Cohttp_lwt_unix.Client.get
(List.map Uri.of_string
[ "http://example.org/";
"http://example2.org/" ])
(* maps the result through the content function *)
let t2 = t >>= Lwt_list.map_p content
(* launch the event loop *)
let v = Lwt_main.run t2
However, when i run
Ocamlbuild file.native
I get unbound module errors.
These modules were installed via opam and when I run
ocamlfind query lwt
/home/chris/.opam/system/lib/lwt
ocamlfind query cohttp
/home/chris/.opam/system/lib/cohttp
How do I get Ocamlbuild to find these two packages?
I have tried
Ocamlbuild -pkgs cohttp,lwt file.native
and it did not work. It said something about a possibly incorect extension. I don't think that is the problem though.
If anyone can give me the correct code to do this it would be greatly appreciated. Thanks!