There’s no exact equivalent of course, but you can get pretty far by putting the type in its own module and just never opening it:
module Facing = {
@unboxed
type t = | @as(true) Up | @as(false) Down
}
let f = v => {
switch v {
| Facing.Up => Console.log("up")
| Down => Console.log("down")
}
}
This works because putting it in its own module hides it to the outside world, unless you explicitly open it. So, the compiler won’t be able to infer that it’s Facing.t you’re after unless you also qualify it with the Facing module, so the compiler knows where to look for the variant constructors.