以下代码使用Core v0.14(ocaml 4.10(成功编译,但使用v0.15(ocaml 4.11(失败。
open Core;;
let command = Command.basic ~summary:"essai" (
let open Command.Let_syntax in
let%map_open s = anon(sequence ("n" %: int)) in
fun () ->
List.iter s ~f:(fun x -> Printf.printf "n = %dn" x ) ;
)
let () = Command.run ~version:"0.0" ~build_info:"RWO" command;;
错误(4.11(:
File "cli.ml", line 10, characters 9-20:
10 | let () = Command.run ~version:"0.0" ~build_info:"RWO" command;;
^^^^^^^^^^^
Error (alert deprecated): Core.Command.run
[since 2021-03] Use [Command_unix]
File "cli.ml", line 10, characters 9-20:
10 | let () = Command.run ~version:"0.0" ~build_info:"RWO" command;;
^^^^^^^^^^^
Error: This expression has type [ `Use_Command_unix ]
This is not a function; it cannot be applied.
Core.Common.run的文档表明它已经过时了,但我找不到如何替换它
我认为您正在寻找收到的消息所指示的Command_unix
。Command_unix.run
的文档链接。
核心库在0.15版本中进行了重组:Unix特定的模块和函数已移至core_unix
库,以使主core
库更具可移植性(或至少与javascript兼容(。
core_unix
库中的函数Command_unix.run
与以前版本的core
库中的Command.run
函数完全相同。