As for the rest of your work, thank you for these tutorials. Here are my 2 cents (somewhat opinionated).
I think modules and functors, as they are constructs of the language, should be presented independently of dune (and also of utop). I do think most of your examples would be fine with just using plain ocamlc/ocamlopt
, if the goal is to explain the language constructs. For modules of course, an important part is their interaction with files and how .ml/.mli files map to modules and signatures.
And it would be fine (imho) if at the end of module tutorial you ended up with 4 ocamlc
lines to build your example. The conclusion could be that yes, modules are a fine language construct, but compiling everything by hand is tedious. There are various ways to simplify this:
- Makefiles (with some tutorials, probably in the advanced concepts section. They would have the virtue of explaining how to do things “from scratch” and what you can do if, for some reason, you cannot use dune for your project, or integrate with a project not yet using dune)
- dune. Here, i think it is important to highlight (even more than you did) that dune helps you organise your code by allowing you to group together several module files under a common toplevel name and that’s what dune calls a library. dune can also build programs (executable). And libraries and executables can be grouped into a package, so that they can be distributed together.
I think this is important to make this distinction and explain these concepts (even to newcomers). Of course what you don’t want to explain is how dune achieves this (module aliases, Foo__A.ml …). And explain that they are a convention (used by dune) to organise OCaml programs, beyond what the plain compiler defines. Because (unfortunately) these concepts are overloaded in our ecosystem (the compiler also has a notion of library, cma/cmxa files, that is very much not the same thing) and newcomers could be confused when they read other materials referring to these other concepts.
This would have the advantage that the module and functor tutorial would be (as much as possible) dune independent the same way the List and Array tutorials are.