LMMarsano.SumType

Some discriminated unions for C♯ 8.


Keywords
discriminated, union, sum, type, tagged, algebraic, data, maybe, either
License
CNRI-Python-GPL-Compatible
Install
Install-Package LMMarsano.SumType -Version 0.0.0

Documentation

SumType

Discriminated union types often found in functional programming languages such as Haskell.

Description

Handle null through a proper type system that excludes it so you don’t have to keep checking. Instead of throwing exceptions, return them as values that short-circuit further evaluation. Let your functions return alternative data types. This library provides types and LINQ-inspired methods to handle such types.

Requirements

C♯ 8.0 with nullable reference types enabled, e.g.,

<NullableContextOptions>enable</NullableContextOptions>

in the .csproj project file.

Installation

To add the package to a project, change directory to the project, and

dotnet add package LMMarsano.SumType

Development

Install at least .NET Core 3.0, clone the repository, change into the directory, and build.

git clone https://github.com/lmmarsano/sumtype.git
Set-Location -Path sumtype
dotnet build

Edit sources in source\SumType. For Visual Studio Code

code source\SumType