DiscriminatedUnion NuGet Package

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




Got any DiscriminatedUnion Question?





Info

Version: 1.0.0.45
Author(s): David Lewis
Last Update: Friday, August 4, 2017
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/sdedalus/DiscriminatedUnion
NuGet Url: https://www.nuget.org/packages/DiscriminatedUnion


Install
Install-Package DiscriminatedUnion
dotnet add package DiscriminatedUnion
paket add DiscriminatedUnion
DiscriminatedUnion Download (Unzip the "nupkg" after downloading)

2 packages depend on this package.


Tags



STATS

must-have-score

avg-downloads-per-day

0

days-since-last-release

2666