ocaml错误:此表达式的类型为expr,但此处与类型单位一起使用 - > EXPR

时间:2013-01-25 00:06:42

标签: ocaml ocamlbuild

我无法弄清楚这个错误意味着什么,我以前从未见过 它抱怨的行是包含x - >的行。让 我之前使用的是匹配,但它仍然给我同样的错误。

let rec build (rand,depth) = match depth with
 | 0 -> if rand(0,2) == 0 then buildX else buildY
 | x -> let r =  rand(0, 5) in
     if r == 0 then buildSine (build (rand, x -1))
     else if r == 1 then buildCosine (build (rand, x -1))
     else if r == 2 then buildAverage (build (rand,x -1), build (rand,x-1))
     else if r == 3 then buildTimes (build (rand, x -1), build (rand, x-1))
     else buildThresh (build(rand, x-1), build(rand, x-1),               
                   build(rand, x-1), build(rand, x-1));;

我的每个构建都返回一个expr,这应该构建一个大的expr 任何帮助将不胜感激。提前致谢! :d

1 个答案:

答案 0 :(得分:3)

或许buildXbuildY应该参与争论?

# let f () = 14;;
val f : unit -> int = <fun>
# f ;;
- : unit -> int = <fun>
# f ();;
- : int = 14