3 ms·
I've always considered both the union and tagged union to be Sum types[0]. > Two common classes of algebraic types are product types (i.e., tuples and records)
by karmakaze 6y ago
I've always considered both the union and tagged union to be Sum types[0].
> Two common classes of algebraic types are product types (i.e., tuples and records) and sum types (i.e., tagged or disjoint unions, coproduct types or variant types).
Edit: e.g. X | Y isn't so different from 'a' A | 'b' B
[0] https://en.wikipedia.org/wiki/Algebraic_data_type https://en.wikipedia.org/wiki/Algebraic_data_type
- nybble41 6y ago> X | Y isn't so different from 'a' A | 'b' B Except for the fact that the union of a type with itself (X | X) doesn't add any extra values, while a tagged union can have distinct tags with the same data type ('a' A | 'b' A) and actually sums the possible values for each tag. They are equivalent only so long as the unions are disjoint with no overlap between the members.
- karmakaze 6y agoI think we're saying the same thing. I was saying it's like thinking of 'a' A as an X and 'b' B as a Y.