ocaml 说在 camllight 中应该是 运行 的表达式中存在语法错误

ocaml says there is a syntax error in the expression supposed to be run in camllight

我正在关注这篇论文:Introduction to Functional Programming。在关于 ML 语言家族的章节中,有 运行 和 camllight 的示例。但是,在 Debian 存储库中,我没有找到任何包含 camllight 的软件包,所以我使用 ocaml 代替:

$ ocaml
    OCaml version 4.01.0

本文中的示例代码在自定义类型定义部分之前运行良好:

#type ('a,'b)sum = inl of 'a | inr of 'b;;

尝试使用 ocaml 输出:

# type ('a,'b)sum = inl of 'a | inr of 'b;;
Error: Syntax error

第一个 of 有下划线。

为什么语法错误? camllight 的某些语言功能是否存在于 ocaml 中?或者我能以某种方式启用它吗?

这个有效:

# type ('a,'b)sum = Inl of 'a | Inr of 'b;;

在 OCaml 中,您需要将构造函数的首字母大写。

Edit1:我还注意到,在您链接的论文中,他的构造函数的首字母大写。我还在 caml light 文档中注意到他们也使用相同的符号。 所以这可能是论文中的错误?

Edit2:我最终安装了 caml light,在 caml light 中首字母大写似乎无关紧要。与 OCaml 不同,任何一种方式都可以。