什么';这个ocaml代码段的含义是什么?

什么';这个ocaml代码段的含义是什么?,ocaml,Ocaml,我无法从ocaml编译器源代码中理解此ocaml代码: File: d:\src\ocaml-4.07.0\driver\pparse.ml 50: type 'a ast_kind = 51: | Structure : Parsetree.structure ast_kind 52: | Signature : Parsetree.signature ast_kind 这里定义了一个类型ast_kind,定义了类型参数'a,但没有使用它 我知道类型define的常见用法如下: type a

我无法从ocaml编译器源代码中理解此ocaml代码:

File: d:\src\ocaml-4.07.0\driver\pparse.ml
50: type 'a ast_kind =
51: | Structure : Parsetree.structure ast_kind
52: | Signature : Parsetree.signature ast_kind
这里定义了一个类型ast_kind,定义了类型参数'a,但没有使用它

我知道类型define的常见用法如下:

type a=
|A of int
|B of int
那么

Structure : Parsetree.structure ast_kind
意思是什么?结构的类型是Parsetree.Structure?还是其他的

我读了官方文件:

它告诉我只有在记录的定义中才能使用“:”

那么这个代码段的含义是什么呢?谢谢

开始于:

    50: type 'a ast_kind =
    51: | Structure : Parsetree.structure ast_kind
    52: | Signature : Parsetree.signature ast_kind
全文如下:

第50行:我们定义一个参数化类型
ast\u kind
,其参数为
'a
。该参数稍后在第51行和第52行中定义。 第51行:
'a
参数类型为
Parsetree.structure
第52行也是如此

现在,更一般地说,
ast_kind
是GADT类型(广义代数数据类型),请参见和另一个示例:

请注意,OCAML4.00中引入了GADT,因此您引用的有关文档的链接对于该特定功能已经过时,因为它引用了OCAML3.12。您当前正在检查OCAML4.07的源代码

    50: type 'a ast_kind =
    51: | Structure : Parsetree.structure ast_kind
    52: | Signature : Parsetree.signature ast_kind