Skip to content

Your own OCaml modules, as with a compiler ​

In Basthon, you can open your own .ml files (Open menu or module= URL parameter) to use them as modules. Loading them is now close to separate compilation:

  • a module is only loaded when first used: stack.ml can use Queue even if it is opened before queue.ml;
  • an interface queue.mli constrains the module, and hides what it does not declare;
  • the errors of a module are shown in the cell that uses it, with the excerpt of the file at fault;
  • a student's module takes precedence over the modules opened by Basthon: a file.ml (the queue of the French course, "file" in French) is no longer hidden by js_of_ocaml's File module;
  • a module opened again after a change is reloaded, and circular dependencies are reported.

Play with it!

User modules, their interface and their errors