【发布时间】:2015-08-12 17:36:32
【问题描述】:
感谢您的关注。我遇到了一个 ocaml 函数调用问题。在这里。
这是函数定义。假设这些是在 pp.ml 中定义的。
let ast_exp_to_string = pp2string (fun p -> p#ast_exp ~prec:0)
let ast_exp_to_string_in_varctx ctx = pp2string_with_pp ctx
(fun p-> p#ast_exp ~prec:0)
let pp2string f v =
let strpp = new pp ft in
pp2string_with_pp strpp f v
let pp2string_with_pp pp f v =
Format.pp_open_box ft 0;
f pp v;
Format.pp_print_flush ft ();
let s = Buffer.contents buf in
Buffer.reset buf;
s
let make_varctx () =
new pp ft
我可以像这样成功调用ast_exp_to_string Pp.ast_exp_to_string e
但是当我用
调用 ast_exp_to_string_in_varctx let varctx = Pp.make_varctx;;
Pp.ast_exp_to_string_in_varctx varctx e
我得到如下编译错误:
Error: This expression has type unit -> Pp.pp
but an expression was expected of type
< ast_exp : prec:int -> 'a -> 'b; .. >
你能帮我看看吗?有什么问题?提前致谢!
【问题讨论】:
标签: ocaml