Excuse the inflammatory title. I saw today this tutorial, and it has a disclaimer at the top that it was written with AI assistance and reviewed by the OCaml.org team:
Managing Dependencies With opam · OCaml Documentation (permalink to the source at the time of writing)
I’m a bit sad to see this. Partly because I detest AI writing, but also because the quality of the tutorial is in my opinion quite poor. First of all, opam.ocaml.org has decent documentation already: opam - Documentation index I can understand there could be a need for a tutorial-style introduction to using opam, but I think the tutorial should link very early to the fine opam documentation. Instead, at the end we find a link to the “opam documentation for more details on the opam syntax” which links to a random section in the middle of the opam manual on package variables(?!)
Let’s analyze the first page or so of the tutorial. It starts early suggesting you run
opam install . --deps-only --with-test --with-doc --with-dev-setup
This is not bad advice, but there is no explanation or motivation for the army of flags in this invocation. Next, we have:
If you prefer to install your dependencies in a global switch instead, select it first:
opam switch set <switch_name> eval $(opam env) opam install . --deps-only --with-test --with-doc --with-dev-setup
First of all, this doesn’t actually work if you have a local switch as suggested you do in the beginning of this tutorial. The local switch will be used.
Once the dependencies have been installed successfully, and assuming the project uses Dune as the build system, you can compile it with:
opam exec -- dune buildOr if you set your environment with
eval $(opam env):dune build
Now we have some confusion here. We were just told to run eval $(opam env) and then we do opam exec -- ... anyway?! And then we get explained if we do the thing we were just told to do we can write it differently. And no mention of the shell hooks the reader hopefully installed makes all this unnecessary.
I will end my rant here, and I hope we can have a constructive discussion on what quality we can expect of the tutorials on ocaml.org. I know there are people on the OCaml community with excellent technical writing skills. Maybe ocaml.org shouldn’t try to write tutorials for everything, and maybe more collect links to existing documentation.