类型定义中的ocaml未绑定构造函数类型错误

类型定义中的ocaml未绑定构造函数类型错误,ocaml,Ocaml,我希望在代码中使用日期和时间,因此我使用opam加载了日历库。我有一段简单的代码来演示这个问题(example.ml): 据我所知,日历日的月份方法的类型签名为date->int 当我尝试编译这段代码(corebuild-pkg calendar example.byte)时,我得到以下错误: File "example.ml", line 3, characters 15-19: Error: Unbound type constructor date 在我看来,编译器正在为日期类型寻找一个

我希望在代码中使用日期和时间,因此我使用opam加载了日历库。我有一段简单的代码来演示这个问题(example.ml):

据我所知,日历日的月份方法的类型签名为
date->int

当我尝试编译这段代码(
corebuild-pkg calendar example.byte
)时,我得到以下错误:

File "example.ml", line 3, characters 15-19:
Error: Unbound type constructor date
在我看来,编译器正在为日期类型寻找一个日期构造函数


我做错了什么?

您想要使用的函数和数据类型在中,因此我们可以重新表述您的代码(我还随意重写了输出短语并插入了缺少的括号):

一个小测试(顺便说一句,你不需要
corebuild


您希望使用的函数和数据类型都在中,因此我们需要重新表述您的代码(我还随意重写了输出短语并插入了缺少的括号):

一个小测试(顺便说一句,你不需要
corebuild

File "example.ml", line 3, characters 15-19:
Error: Unbound type constructor date
open CalendarLib

type datefun = Date.t -> int

let run_datefun (f : datefun) (d : Date.t) = (f d)

let () =
  let mydate = Date.make 2016 5 23 in
  Printf.printf "# of days in current month = %i\n" (run_datefun Date.days_in_month mydate)
$ ocamlbuild -pkg calendar example.ml example.byte
Finished, 3 targets (3 cached) in 00:00:00.

$ _build/calendar.byte
# of days in current month = 31