Tkheikkila.FunctionalTypes 2.0.0

dotnet add package Tkheikkila.FunctionalTypes --version 2.0.0
                    
NuGet\Install-Package Tkheikkila.FunctionalTypes -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Tkheikkila.FunctionalTypes" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tkheikkila.FunctionalTypes" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Tkheikkila.FunctionalTypes" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Tkheikkila.FunctionalTypes --version 2.0.0
                    
#r "nuget: Tkheikkila.FunctionalTypes, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Tkheikkila.FunctionalTypes@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Tkheikkila.FunctionalTypes&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Tkheikkila.FunctionalTypes&version=2.0.0
                    
Install as a Cake Tool

Tkheikkila.FunctionalTypes

Useful types missing from C#

Inspired by Rust's std::unit, std::option::Option, and std::result::Result.

Unit

AKA: void

Contains no information other that it's type.

Maybe<T>

AKA: Option or Optional

A value that may or may not contain a value of type T.

This type has two states:

  • Some that contains a single value of type T
    Created by calling Maybe<T>.Some(value).
  • None that contains no value
    Created by calling Maybe<T>.None() or by returning default.

Result<TValue, TError>

AKA: Either

A value that can be in one of two states, but never both.

These states are:

  • Ok that indicates success with a value of type TValue
    Created by calling Result<TValue, TError>.Ok(value).
  • Error that indicates failure with a value of type TError
    Created by calling Result<TValue, TError>.Error(error)

MaybeResult<TValue, TError>

A combination of Maybe<T> and Result<TValue, TError>.

Equivalent to Maybe<Result<TValue, TError>>

Resembles Result<Maybe<TValue>, TError> and Result<TValue, Maybe<TError>>

This type has three states:

  • Ok that indicates success with a value of type TValue Created by calling MaybeResult<TValue, TError>.Ok(value).
  • Error that indicates failure with a value of type TError Created by calling MaybeResult<TValue, TError>.Error(error).
  • Neither that indicates that neither a value of type TValue nor a value of type TError is present Created by calling MaybeResult<TValue, TError>.Neither().

GreedyValidationResult<TValue, TError>

A value that contains a value of type TValue and a collection of errors of type TError.

Resembles Result<TValue, List<TError>> with a value of type TValue that is always present.

Resembles LazyValidationResult<TValue, TError> with a collection of errors of type TError.

This type has two states:

  • Valid that contains no errors
  • Invalid that contains one or more errors of type TError

Created by calling Validation.Greedy<TValue, TError>(value).

Errors can be added by calling AddError(error), one of the AddErrors overloads, or one of the Validate overloads that returns a value of TError.

LazyValidationResult<TValue, TError>

A value that contains a value of type TValue. If the value is invalid, it also contains a single error of type TError.

Resembles GreedyValidationResult<TValue, TError> with a maximum of one error.

Resembles Result<TValue, TError> with a value of type TValue that is always present.

This type has two states:

  • Valid that contains no errors
  • Invalid that contains single error of type TError

Created by calling Validation.Lazy<TValue, TError>(value).

Error can be set by calling one of the Validate overloads that returns a value of TError.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.0 124 11/14/2024
2.0.0-rc.4 65 11/14/2024
2.0.0-rc.3 57 10/22/2024
1.0.0 571 6/3/2022