Cannot get cohttp_eio to work


on my journey of learning ocaml I am trying to use cohttp-eio. I just copied the example from the repository:

open Cohttp_eio

let () = Logs.set_reporter (Logs_fmt.reporter ())

and () =
  (* The eio backend does not leverage domains yet, but might in the near future *)
  Logs_threaded.enable ()

and () = Logs.Src.set_level Cohttp_eio.src (Some Debug)

let () = @@ fun env ->
  let client = Client.make env#net in @@ fun sw ->
  let resp, body = Client.get ~sw client (Uri.of_string "") in
  if resp.status `OK = 0 then
    print_string @@ Eio.Buf_read.(parse_exn take_all) body ~max_size:max_int
  else Fmt.epr "Unexpected HTTP status: %a" Http.Status.pp resp.status

But dune build gives me:

File "bin/", line 9, characters 28-42:
9 | and () = Logs.Src.set_level Cohttp_eio.src (Some Debug)
Error: Unbound value Cohttp_eio.src

If I comment out the set_level line I get:

11 |   let client = Client.make env#net in
Error: Unbound value Client.make
Had 1 error, waiting for filesystem changes...

Any Idea what is going wrong here?

It seems that you want to use these examples, as they are in sync with the latest (alpha) release.

Indeed Cohttp_eio.src did not exist in august

Or maybe explore from cloning the repo?

See here for a working example: Use cohttp-eio server by yawaramin · Pull Request #1 · chrstntdd/ocaml_http · GitHub

Pay especially close attention to the library dependencies inside the dune file.