简体   繁体   中英

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 call.byte -no-hygiene

I tried add -pkgs 'core', but that didn't work as well.

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. It's part of the language as specified. If your compiler really can't locate the List module then something is wrong.

One possibility is that your installation is messed up and doesn't have the List module. The first thing to try for this case would be to reinstall OCaml on your system if possible.

Here's how I can find the Stdlib module (the actual file) for my installation.

$ 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. In other words, maybe your environment has replaced List with something new. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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