top | item 29152890 (no title) tonicbbleking | 4 years ago Discriminated unions is one of those features that everyone talks about, but never gets championed. Wish C# 10 already had this feature. https://github.com/dotnet/csharplang/discussions/2962 discuss order hn newest keithnz|4 years ago you can actually do them pretty easily in C# without language support anyways.for instance, the F# example from https://fsharpforfunandprofit.com/posts/designing-for-correc...can be done in C# like https://gist.github.com/keithn/ceeeed5f7eb567e1b2333747065d1...almost similar amount of code, however, no exhaustive checking. Not that I find that to be much of a problem, but it would be nice Smaug123|4 years ago But who needs sum types when you have the visitor pattern :troll_face:https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/ load replies (1) throw868788|4 years ago Maybe try F#? I know it isn't always an option but if you can, especially recently, its been quite productive to work in.
keithnz|4 years ago you can actually do them pretty easily in C# without language support anyways.for instance, the F# example from https://fsharpforfunandprofit.com/posts/designing-for-correc...can be done in C# like https://gist.github.com/keithn/ceeeed5f7eb567e1b2333747065d1...almost similar amount of code, however, no exhaustive checking. Not that I find that to be much of a problem, but it would be nice Smaug123|4 years ago But who needs sum types when you have the visitor pattern :troll_face:https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/ load replies (1)
Smaug123|4 years ago But who needs sum types when you have the visitor pattern :troll_face:https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/ load replies (1)
throw868788|4 years ago Maybe try F#? I know it isn't always an option but if you can, especially recently, its been quite productive to work in.
keithnz|4 years ago
for instance, the F# example from https://fsharpforfunandprofit.com/posts/designing-for-correc...
can be done in C# like https://gist.github.com/keithn/ceeeed5f7eb567e1b2333747065d1...
almost similar amount of code, however, no exhaustive checking. Not that I find that to be much of a problem, but it would be nice
Smaug123|4 years ago
https://blog.ploeh.dk/2018/06/25/visitor-as-a-sum-type/
throw868788|4 years ago