【发布时间】:2018-08-14 11:36:54
【问题描述】:
当我将字节变量从Core_extended 传递给方法Shell.sh_one 时,出现了一个奇怪的错误:
Error: This expression has type bytes but an expression was expected of
type
('a, unit, bytes, bytes option) Core.Std.format4 =
('a, unit, bytes, bytes, bytes, bytes option) format6
如果我传递字节字面量,有趣的是,没有错误。有人可以解释 Ocaml 的这种行为吗?下面是来自 Ocaml utop 的列表:
# #require "core_extended";;
# open Core_extended.Std;;
# let cmd = "ls -al /";;
val cmd : bytes = "ls -al /"
# "ls -al /";;
- : bytes = "ls -al /"
# Shell.sh_one "ls -al /";;
- : bytes option =
Some
"lrwxrwxrwx 1 root root 30 sty 29 09:28 vmlinuz.old -> boot/vmlinuz-4.13.0-32-generic"
# Shell.sh_one cmd;;
Error: This expression has type bytes but an expression was expected of type
('a, unit, bytes, bytes option) Core.Std.format4 =
('a, unit, bytes, bytes, bytes, bytes option) format6
【问题讨论】:
标签: ocaml ocaml-core