相关疑难解决方法(0)

OCaml Printf.sprintf

为什么会出现这种情况?

# Printf.sprintf ("Foo %d %s") 2 "bar";;
- : string = "Foo 2 bar"

# Printf.sprintf ("Foo %d" ^ " %s") 2 "bar";;
  Printf.sprintf ("Foo %d" ^ " %s") 2 "bar";;
Error: This expression has type string but an expression was expected of type
         ('a -> 'b -> 'c, unit, string) format =
           ('a -> 'b -> 'c, unit, string, string, string, string) format6
Run Code Online (Sandbox Code Playgroud)

我希望首先评估字符串连接,所以一切都会正常进行.这与Printf采用的类型系统技巧有关吗?

printf ocaml type-systems

11
推荐指数
2
解决办法
1万
查看次数

标签 统计

ocaml ×1

printf ×1

type-systems ×1