Ocaml 模式匹配中变量的别名

Ocaml 模式匹配中变量的别名,ocaml,Ocaml,我经常有类似于以下内容的内容(树的标准类型定义): 在其他语言中,可以执行以下操作: match tree with | Branch(v, tl@Branch(_, _, _), _) = f tl OCaml有类似的功能吗?这是使用OCaml中的as关键字来完成的: match tree with | Branch(v, (Branch(_, _, _) as tl), _) = f tl 这对我来说是无法编译的,尽管如果我在parenthesis@Cjen1对,我错了。如果没有

我经常有类似于以下内容的内容(树的标准类型定义):

在其他语言中,可以执行以下操作:

match tree with
    | Branch(v, tl@Branch(_, _, _), _) = f tl

OCaml有类似的功能吗?

这是使用OCaml中的
as
关键字来完成的:

match tree with
| Branch(v, (Branch(_, _, _) as tl), _) = f tl

这对我来说是无法编译的,尽管如果我在parenthesis@Cjen1对,我错了。如果没有括号,则将
v,Branch(,,,)
作为
as
的左操作数。
match tree with
| Branch(v, (Branch(_, _, _) as tl), _) = f tl