▲ | dfabulich 3 days ago | ||||||||||||||||||||||
I strongly agree. Algebraic types aren't "scary," but "algebraic types" is a bad term for what they are. In all popular languages that support "sum types" we just call them "unions." Your favorite programming language probably already supports unions, including Python, TypeScript, Kotlin, Swift, PHP, Rust, C, and C++. C# is getting unions next year. The article never mentions the word "union," which is overwhelmingly more likely to be the term the reader is acquainted with. It mentions "sets" only at the start, preferring the more obscure terms "sum types" and "product types." A union of type sets kinda like a sum, but calling it a "sum" obscures what you're doing with it, rather than revealing. The "sum" is the sum of possible values in the union, but all of the most important types (numbers, arrays, strings) already have an absurdly large number of possible values, so computing the actual number of possible values is a pointless exercise, and a distraction from the union set. Stop trying to make "algebraic" happen. It's not going to happen. | |||||||||||||||||||||||
▲ | chrisnight 3 days ago | parent | next [-] | ||||||||||||||||||||||
> In all popular languages that support "sum types" we just call them "unions." When I was doing research on type theory in PL, there was an important distinction made between sum types and unions, so it’s important not to conflate them. Union types have the property that Union(A, A) = A, but the same doesn’t hold for sum types. Sum types differentiate between each member, even if they encapsulate the same type inside of it. A more appropriate comparison is tagged unions. | |||||||||||||||||||||||
| |||||||||||||||||||||||
▲ | dkarl 3 days ago | parent | prev [-] | ||||||||||||||||||||||
> Stop trying to make "algebraic" happen. It's not going to happen It's been used for decades, there's no competitor, and ultimately it expresses a truth that is helpful to understand. I agree that the random mixture of terminology is unhelpful for beginners, and it would be better to teach the concepts as set theory, sticking to set theoretic terminology. In the end, though, they'll have to be comfortable understanding the operations as algebra as well. | |||||||||||||||||||||||
|