// Foo and Bar cannot be assigned to each other
type Foo = Foo of int
type Bar = Bar of int
// Foo and Bar can be assigned to each other
type Foo = int
type Bar = int
The first variant uses single-case unions. It's a bit unfortunate that they also default to classes over structs unless you annotate them with [<Struct>], partially fixed by escape analysis though.
The enum trick is the tersest and will also serialize correctly in most cases, but I have never seen anyone use it like that before.
The enum trick is the tersest and will also serialize correctly in most cases, but I have never seen anyone use it like that before.