PG.FunctionalExt
0.2.2
dotnet add package PG.FunctionalExt --version 0.2.2
NuGet\Install-Package PG.FunctionalExt -Version 0.2.2
<PackageReference Include="PG.FunctionalExt" Version="0.2.2" />
<PackageVersion Include="PG.FunctionalExt" Version="0.2.2" />
<PackageReference Include="PG.FunctionalExt" />
paket add PG.FunctionalExt --version 0.2.2
#r "nuget: PG.FunctionalExt, 0.2.2"
#:package PG.FunctionalExt@0.2.2
#addin nuget:?package=PG.FunctionalExt&version=0.2.2
#tool nuget:?package=PG.FunctionalExt&version=0.2.2
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 | Versions 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. |
-
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.