Skip to content

nabond251/dotnet-sealed-unions

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

.NET Sealed Unions

Yet Another Coproducts Port
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Usage
  3. Roadmap
  4. Contributing
  5. License
  6. Contact
  7. Acknowledgments

About The Project

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.

(back to top)

Usage

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).

(back to top)

Roadmap

  • Improve documentation
  • Integrate with C# 9 switch pattern matching

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the Apache-2.0 license. See LICENSE.txt for more information.

(back to top)

Contact

Nathaniel Bond - @bondolin_7 - nabond251@gmail.com

Project Link: https://github.com/nabond251/dotnet-sealed-unions

(back to top)

Acknowledgments

(back to top)