Yet Another Coproducts Port
Explore the docs »
View Demo
·
Report Bug
·
Request Feature
Table of Contents
This is a .NET port of Francisco (Paco) Estévez's JavaSealedUnions.
In computer science, a tagged union, also called a variant, variant record, choice type, discriminated union, disjoint union, sum type or coproduct, is a data structure used to hold a value that could take on several different, but fixed, types.
— Wikipedia, Tagged Union
And apparently now "sealed union" works, too. This structure is the
counterpart to the tuple. A tuple allows you to form expressions which model
data0
and data1
and data2
; a tagged union allows you to model data0
or data1
or data2
. Several languages either support this structure
natively, or have supplied a library implementing it. The sealed union flavor
is a simple, elegant implementation of such a library, so here it is for .NET.
A simple way to get a feel for the workings of this library would be to clone this repository and run the xUnit tests. One implements the Tennis kata (see The Tennis kata revisited by Mark Seemann).
- Improve documentation
- Integrate with C# 9
switch
pattern matching
See the open issues for a full list of proposed features (and known issues).
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the Apache-2.0 license. See LICENSE.txt
for more information.
Nathaniel Bond - @bondolin_7 - nabond251@gmail.com
Project Link: https://github.com/nabond251/dotnet-sealed-unions