3 ms·
You should be able to commute terms of an union without changing its identity. So this is not the right solution I'm afraid.
by aatd86 2y ago
You should be able to commute terms of an union without changing its identity.
So this is not the right solution I'm afraid.
- noelwelsh 2y agoI must admit I don't understand what you are trying to say here. Perhaps there is some confusion around terminology. What OP calls union types are known in type theory as sum types, and are actually different from what type theory calls union types. Type theory union types are like set unions.
- aatd86 2y agoYou can't have the zero value of a union be the zero value of the first written term or (a | b) becomes different from (b | a).
- noelwelsh 2y agoCommutativity doesn't apply to sum types, though it does apply to union types. Here I'm using the type theory terms, not the terms used by OP. So this isn't really an issue. Zero values don't make any sense anyway. As the original comment said "You might think this is a pretty dumb design decision that can lead to programmer error, but it meshes perfectly with the other mistakes in the language."