I'm basically trying to follow this stackoverflow answer located in this post:
What is the best module for HttpRequest in OCaml
and I'm running in to problems. When I am trying to run a single file with just
open Lwt ;;
I am getting and error saying it is an unbound module. I have run the following opam instruction:
opam install lwt
and it did install the correct package.
So I think the problem is the difference between a module and a package, which I don't really understand. I was looking at this question as a possible answer, but I wasn't sure if it was what I needed.
Unbound modules in OCaml
Thanks for the input guys, I'm new to Ocaml and I'm trying to learn the ins and outs of building something.
ocaml modules allow to package together data structures definitions and functions operating on them. This allow to reduce code size and name confusion, as any identifier can appear in different modules, with different meanings, without any interference.
However, it is often assumed that while a package is a collection of modules, a library is a collection of packages.
In OCaml, the *. mli file is the exported signature of the module, and the compiler strictly enforces it. In most cases for a module called Foo you will find two files: foo.ml and foo. mli . foo.ml is the implementation and foo.
A functor is a module that is parametrized by another module, just like a function is a value which is parametrized by other values, the arguments. It allows one to parametrize a type by a value, which is not possible directly in OCaml without functors.
To use a "package", you must tell the compiler about it explicitly. Unbound module in OCaml usually means one of two things: your made a typo of the module name, or you failed to set a proper module search path. What compiler options do you use?
If you use ocamlfind, the compilation should look like:
ocamlfind ocamlc -package lwt -c mymodule.ml
this instructs the compiler to try to find modules in lwt package installation directory, in addition to the default ones.
if you do not use ocamlfind.... well, use ocamlfind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With