Re:Safer Enums in Go
by nicoburns on Saturday May 14, 2022 @09:51AM
(#31377915)
“algebraic data types” includes product types (aka structs, classes and tuples) as well as sum types (aka enums and probably other names)
[ Parent
| on HN ]
Rust's "enums" also include products. Each case can have multiple arguments. That's a sum of products. "Algebraic data type" is the proper term for what Rust calls "enums", since they encompass both sums and products.
(It is also true that structs are products. But that isn't relevant.)
Rust's syntax makes plenty of concessions to familiarity, as a way of making up for the much more important and irreducible unfamiliarity that it brings to the table (e.g. ownership). Originally Rust used the keyword `tag` here (for "tagged unions"), then vacillated between `enum` and `union` for years and years prior to 1.0.