4 ms·
I don't think tag is an implementation detail generally, for example: enum Option<T> { None, Some(T), } The tags are "None" and "Some"
by tubthumper8 2y ago
I don't think tag is an implementation detail generally, for example:
enum Option<T> {
None,
Some(T),
}
The tags are "None" and "Some" which are definitely user facing.
But I see what they mean a bit with the C# example:
union U
{
A(int x, string y);
B(int z);
C;
}
So it seems like "A", "B", and "C" are tags but also their own distinct types, with a implicit conversions between those and the overall union type
- tialaramex 2y agoTagged unions are an implementation detail and are often not the optimal way to solve this problem. Take Option<Infallible>, it's a ZST, not only is there no "tag" there isn't any data at all. In type theory this is fine, we added an empty type to the unit type, we got a unit type.