PG.FunctionalExt 0.2.2

dotnet add package PG.FunctionalExt --version 0.2.2
                    
NuGet\Install-Package PG.FunctionalExt -Version 0.2.2
                    
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="PG.FunctionalExt" Version="0.2.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PG.FunctionalExt" Version="0.2.2" />
                    
Directory.Packages.props
<PackageReference Include="PG.FunctionalExt" />
                    
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 PG.FunctionalExt --version 0.2.2
                    
#r "nuget: PG.FunctionalExt, 0.2.2"
                    
#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 PG.FunctionalExt@0.2.2
                    
#: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=PG.FunctionalExt&version=0.2.2
                    
Install as a Cake Addin
#tool nuget:?package=PG.FunctionalExt&version=0.2.2
                    
Install as a Cake Tool

FunctionalExt

Functional programming types Result and Option

Option Type

The Option type represents a value that may or may not exist. It is useful for modeling optional values without resorting to null references. The Option type has two possible states:

  • Some(value): Represents an existing value.
  • None: Represents the absence of a value.

Example Usage

Option<int> maybeNumber = Some(42);
Option<int> noNumber = None<int>();

maybeNumber.Match(
    some: value => Console.WriteLine($"Value: {value}"),
    none: () => Console.WriteLine("No value")
);

Result Type

The Result type represents the outcome of an operation that can either succeed or fail. It is useful for error handling without using exceptions. The Result type has two possible states:

  • Success(value): Represents a successful result with a value.
  • Fail(error): Represents a failure with an error.

Example Usage

Result<int, GenericError> divide(int numerator, int denominator)
{
    if (denominator == 0)
        return Fail<int, GenericError>(new GenericError("Division by zero"));
    return Success<int, GenericError>(numerator / denominator);
}

var result = divide(10, 2);
result.Match(
    success: value => Console.WriteLine($"Result: {value}"),
    error: err => Console.WriteLine($"Error: {err}")
);

Installation

To use this library, add it to your project via NuGet:

dotnet add package FunctionalExt

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • 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
0.2.2 171 8/20/2025
0.2.1 249 8/6/2025
0.2.0 235 8/6/2025
0.1.0 193 4/13/2024