3 ms·
> Also I think the name 'sum type' is bad. Nothing gets added or summed up If you view types as sets of values, then a sum type is the addition (union) of two
by masklinn 9y ago
> Also I think the name 'sum type' is bad. Nothing gets added or summed up
If you view types as sets of values, then a sum type is the addition (union) of two sets, while a product type is the product (combination) of two sets.
> For this reason I find supercharging 'enum', like Swift does, a more logical solution.
Both are logical, they just come from different trains of thought.
Extending "enum" comes from "developers" viewing sum types as extensions of C-style enums, sum types comes from computer science and set theory.