Why are some standard ocaml libraries opam packages and some are not?

205 views Asked by At

I see the base-unix package in the OCaml opam repository . It is described as the "Unix library distributed with the OCaml compiler". Some other libraries that are also distributed with the OCaml compiler do not have their own package. For instance, there is no such thing as a base-str package for the str library.

Why is there such a difference? As far as I can see, they both require to be specified as packages or libraries on the command-line when compiling with ocamlfind or ocamlbuild.

1

There are 1 answers

1
camlspotter On BEST ANSWER

Libraries with OPAM package names base-XXX are optional libraries: they are from OCaml compiler itself, but they may or may not be installed depending on the computer environment, os and build configuration flags of the compiler. Existence of base-unix for example means that unix library is available in that environment.

On the other hand, str library is not system dependent and therefore available anywhere OCaml is installed. Therefore OPAM does not need to provide its base package explicitly to tell the existence of the library.

Though str exists for all the OCaml installations, its linking is not automatic. That's why ocamlfind requires a package for it.

OPAM packages are for installation by opam command. OCamlFind packages are for linking. They are related but different. Confusing but this is what we have in OCaml eco system for now.