简体   繁体   English

OCaml 中的数据类型定义中的方括号 `[` 和 `]` 是什么意思?

[英]What does square brackets `[` and `]` mean in a data type definition in OCaml?

I saw the following :我看到了以下内容

type rlevel = [
| `rlevel
]

but I've never seen this before and the tutorials for ADTs (algebraic data types) are not super helpful nor is the OCaml grammar.但我以前从未见过这种情况,而且 ADT(代数数据类型)的教程不是很有帮助,OCaml 语法也不是。

What does this mean?这是什么意思?

类型rlevel是多态变体类型 ( https://ocaml.org/manual/polyvariant.html ) 的类型缩写,它只包含一个构造函数`rlevel

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM