0

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?

Tech333
  • 41
  • 3
  • I can't reproduce your problem. I get a file named call.byte that does the right thing. `List.length` is in the OCaml standard library (of course). So you might have a general system setup problem. If you're using Core you may have replaced the standard `List` with some other module (say). – Jeffrey Scofield Jul 11 '20 at 16:52
  • I uninstalled core, but that didn't do anything. How would you unistall all of its dependencies? – Tech333 Jul 11 '20 at 17:18
  • The OCaml standard library should always come with an OCaml installation. So if you don't have it, something is wrong. It's hard to say more than this, sorry. – Jeffrey Scofield Jul 11 '20 at 17:19
  • Thanks for the help. Everything was working fine until I installed core. – Tech333 Jul 11 '20 at 17:22

1 Answers1

0

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.

Jeffrey Scofield
  • 65,646
  • 2
  • 72
  • 108