【发布时间】:2016-11-07 17:58:56
【问题描述】:
我正在学习一个教程,该教程解释了如何使用 lwt 和 Cohttp 在 OCaml 中制作一个简单的 Web 服务器。
我有一个 _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.
我不知道如何解决这个问题,所以提前感谢您对此进行调查。
【问题讨论】: