Working union types into C#
spin.atomicobject.com·17h
📐Type Theory
Preview
Report Post

If you’re coming to C# from a language like Typescript, you might be wondering, “how do I write a discriminated union?” Unfortunately, C# does not currently support unions as such, but other language features can get you pretty close. Plus, native support might be just over the horizon.

The State of Union Types in C

A formal proposal to add unions to C# was added last year to the C# language repository. The proposal explores adding a concise syntax for declaring a type that can be one of several named alternatives, each potentially containing its own data payload. A first-class union type would bring C# closer to features that have been widely adopted in functional …

Similar Posts

Loading similar posts...