The keyword to search for is algebraic data types, which are common in functional languages, but for instance Rust also has them.
Here is an example comparing C# with F#, where the latter also algebraic data types: https://blog.ploeh.dk/2016/11/28/easy-domain-modelling-with-...