To switch to a specific version of the compiler, do
opam switch create <compiler-version>
(Note: for the old opam 1.x, it was an opam switch <compiler-version> )
For instance,
opam switch create 4.07.0
Or, if you want to create a new new switch that uses the same compiler as another switch, then the syntax
opam switch create <name> <compiler-version>
For instance,
opam switch create myproj 4.07.0
Please note that if <name> is a folder, a local switch will be created, for example, opam switch./myproj 4.07.0 will create a switch directly in the myproj folder.
To start with a specific version, i.e. When you first install opam, just do
opam init --compiler=<version>
For instance,
opam init --compiler=4.07.0
To view the list of available versions, do
opam switch
To see even more, do
opam switch list-available
source share