简体   繁体   English

Ocaml中的未绑定值列表?

[英]Unbound value List in Ocaml?

I just built a little test program to see my bigger issue, but I keep on getting an error.我刚刚构建了一个小测试程序来查看我的更大问题,但我不断收到错误。

let test a =
   List.length [a;a;a]

I want to build it with ocamlbuild.我想用 ocamlbuild 构建它。

ocamlbuild call.byte -no-hygiene

I tried add -pkgs 'core', but that didn't work as well.我尝试添加 -pkgs 'core',但效果不佳。

This is the error.这是错误。

Error: Unbound value List.length

Any suggestions?有什么建议么?

This isn't really an answer, sorry.这不是一个真正的答案,对不起。 But the comment area is too constrained for giving suggested command lines.但是评论区太受限制,无法给出建议的命令行。

The List module should be installed as part of any OCaml installation. List 模块应该作为任何 OCaml 安装的一部分进行安装。 It's part of the language as specified.它是指定语言的一部分。 If your compiler really can't locate the List module then something is wrong.如果您的编译器确实无法找到 List 模块,则说明有问题。

One possibility is that your installation is messed up and doesn't have the List module.一种可能性是您的安装混乱并且没有 List 模块。 The first thing to try for this case would be to reinstall OCaml on your system if possible.对于这种情况,首先要尝试的是在您的系统上重新安装 OCaml(如果可能)。

Here's how I can find the Stdlib module (the actual file) for my installation.以下是我如何为我的安装找到 Stdlib 模块(实际文件)。

$ ocamlc -where
/Users/self/.opam/4.10.0/lib/ocaml
$ ls -l $(ocamlc -where)/stdlib.cm*a
-rw-rw-r--  1 self  staff  2812632 Mar  2 09:07 \
     Users/jeffsco/.opam/4.10.0/lib/ocaml/stdlib.cma
-rw-rw-r--  1 self  staff    22621 Mar  2 09:07 \
    /Users/jeffsco/.opam/4.10.0/lib/ocaml/stdlib.cmxa

Another possibility is that when you say List you're not talking about the standard List module but about some other module.另一种可能性是,当您说List时,您不是在谈论标准 List 模块,而是在谈论其他一些模块。 In other words, maybe your environment has replaced List with something new.换句话说,也许你的环境已经用新的东西代替了List Some libraries like to do this because they feel they are superior to the standard library (no comment on this feeling).一些库喜欢这样做是因为他们觉得自己优于标准库(对此感觉不做评论)。

If this is what's happening, and if you want to use this other library, then you should read the documentation on the library to find out how to access the standard library functions.如果这是正在发生的事情,并且如果您想使用这个其他库,那么您应该阅读该库的文档以了解如何访问标准库函数。 There is almost always a way to do this.几乎总有办法做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM