我正在关注一个教程,该教程解释了如何在 OCaml 中使用lwt
和Cohttp
.
我有一个_tags
包含以下内容的文件:
true: package(lwt), package(cohttp), package(cohttp.lwt)
还有一个webserver.ml
:
open Lwt
open Cohttp
open Cohttp_lwt_unix
let make_server () =
let callback conn_id req body =
let uri = Request.uri req in
match Uri.path uri with
| "/" -> Server.respond_string ~status:`OK ~body:"hello!\n" ()
| _ -> Server.respond_string ~status:`Not_found ~body:"Route not found" ()
in
let conn_closed conn_id () = () in
Server.create { Server.callback; Server.conn_closed }
let _ =
Lwt_unix.run (make_server ())
然后,ocamlbuild -use-ocamlfind webserver.native
触发以下错误:
Error: Unbound record field callback
Command exited with code 2.
如果我更改为:Server.create { callback; conn_closed }
它也会触发:
Error: Unbound record field callback
Command exited with code 2.
我不知道如何解决这个问题,所以提前感谢您对此进行调查。