How to use opam with a nonstandard compiler/base?

I’m about to start working with ocaml 4.10 (pre-beta), and would like to try to use opam to build it and then install packages, test them out, etc. Looking around, I don’t see a simple way to do this – am I mistaken? I can of course revert to the old-skool way, but I figured if there’s a way to use opam, that’d be nice.

Any advice would be appreciated.

Just add the ocaml-beta-repository:

opam repo add beta
opam switch create 4.10.0+trunk --repositories=default,beta
opam switch 4.10.0+trunk

This appears to work, but the first command gave an error:

[WARNING] No switch is currently set, perhaps you meant '--set-default'?
[beta] Initialised
[ERROR] No switch is currently set. Please use 'opam switch' to set or install
        a switch

The next command did create the switch (without errors) and ocamlc --version confirms that it’s what I desire, so it seems to all work fine.

$ ocamlc --version

I think it should be initialized first with opam init or something like that.

Yep, I did the opam init beforehand. I have a standard script I follow to set up opam sandboxes. But regardless, it all worked out (even with the error).