There are a few things you can do, the simplest being to just choose longer variant names:
@unboxed
type facing = | @as(true) FacingUp | @as(false) FacingDown
let f = v => {
switch v {
| FacingUp => Console.log("up")
| FacingDown => Console.log("down")
}
}
You can of course put it in a module and always prepend the module name as @zth explained!
If you want to add another layer of security, you could also declare it as private and create helper functions to create such variants:
module Facing: {
@unboxed
type t = private | @as(true) Up | @as(false) Down
let up: t
let down: t
} = {
@unboxed
type t = | @as(true) Up | @as(false) Down
let up = Up
let down = Down
}
This way, you can enforce that you have to use the module name to produce such values.