How does one switch ocaml version?

I can’t seem to have the toplevel to be the version I want but I’ve been successfully able to switch between compiler version.

Check the session where I try switching version but the toplevel doesn’t change but the compiler does.

(base) ❯ opam switch list
#  switch   compiler                    description
→  4.05.0   ocaml-base-compiler.4.05.0  4.05.0
   4.06.0   ocaml-base-compiler.4.06.0  4.06.0
   4.07.0   ocaml-base-compiler.4.07.0  4.07.0
   default  ocaml-system.4.07.0         default
(base) ❯ opam switch 4.06.0
(base) ❯ ocaml --version
The OCaml toplevel, version 4.07.0
(base) ❯ opam switch list
#  switch   compiler                    description
   4.05.0   ocaml-base-compiler.4.05.0  4.05.0
→  4.06.0   ocaml-base-compiler.4.06.0  4.06.0
   4.07.0   ocaml-base-compiler.4.07.0  4.07.0
   default  ocaml-system.4.07.0         default

How does one switch OCaml version everywhere consistently? i.e. Toplevel, compiler etc (not sure if there are more things I should make sure to switch)


related question:

Do you have opam’s shell hooks setup? If so then that one command is all you need. Otherwise you need to refresh your environment to point to the newly selected switch. I’m on a phone so I don’t have the specific command handy - I think it’s something along the lines of eval $(opam env)

opam switch 4.07.0