[opam-devel] "Modules"?

Gabriel Scherer gabriel.scherer at gmail.com
Thu Jul 20 07:51:21 BST 2017

Dear opam-devel,

I just learned about "modules" today, which are basically a
declarative language to declare things to add to a Unix environment to
make specific development environments available, much like opam
switch does. They were invented in the 1990s and seem to be used in
the scientific programming community:


(I learned about it in the bugreport against Fedora that I submitted
as a consequence of opam-repository fiddling. I thought it was wrong
of Fedora not to make the openMPI pkg-config files available by
default, but they use modules to allow users to switch from one MPI
implementation to the next, so you have to run `module load
mpi/openmpi-x86_64` first:
https://bugzilla.redhat.com/show_bug.cgi?id=1471512 ).

Would it be possible to reuse modules in opam, that is allow to use
"module load ocaml $switch" as an alternative to "opam switch $switch;
eval $(opam config env)"? They seem to have a nicer user interface
(one command suffices; is there some trick that opam switch could
reuse), and some people know about it already so opam would feel less
alien to them.

One thing that they don't seem to have is the ability to run just a
command under the modified environment (opam config exec
--switch=$switch -- ...), which I find very handy in various
circumstances. I'm not suggesting to permanently replace "opam switch"
by the "module" command, but wondering if supporting both interfaces
would make sense.

More information about the opam-devel mailing list