OCaml模式中的"模式预期"与变体匹配

Fra*_*ini 2 ocaml variant pattern-matching

在尝试编译以下代码段时:

type 'a frame = Empty | Frame of string * 'a * 'a frame

let rec searchFrame f s = match f with
  | Empty -> None
  | Frame(x, val, fr) -> if x == s then
                           Some(val)
                         else
                           searchFrame fr s;;
Run Code Online (Sandbox Code Playgroud)

我Error: Syntax error: pattern expected.在第二个匹配的情况下得到一个错误,对应于val.我无法弄清楚我在这里做错了什么:基本上val应该对应一个类型的值'a,但我要求我放置一个模式.我怎么解决这个问题?

Pie*_* G. 6

val是一个Ocaml关键字 - 只需通过更改val来修改您的代码v.