8 ms·
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
by arendjr 2y ago
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-types/ https://blog.ploeh.dk/2016/11/28/easy-domain-modelling-with-...
- neonsunset 2y agoThe syntax has improved quite substantially since 2016 for pattern matching at C#'s end, and it's very easy to model ADTs with records (and the experience of using them even before that was decent with methods accepting lambdas). Today, you write it in a similar way you would write a match in Rust.
- nequo 2y agoHow do you represent sum types in C# today? Can enum members hold records as data, or do you do it differently?