Skip to content

sdedalus/DiscriminatedUnion

Repository files navigation

DiscriminatedUnion

Implementation of Discriminated Union and Pattern Matching in C#.

string outputValue = x.Match<String>()
						.Case(c => c == "Test", v => "It's Test!")
						.Case(v => "It's Not Test!")
						.Else(() => "It's None!")

or

var x = new Union<string, int>(100);

// the type annotations below are optional and only added for clerity.
string value = x.Match<string>()
	.Case((string v) => v)
	.Case((int c) => c == 100, (int v) => "Keeping It 100.")
	.Case((int v) => "Tea?")
	.Else(() => "Nothing");

Assert.Equal("Keeping It 100.", value);

About

Implementation of DiscriminatedUnion in C#.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published