FluentUtils.Monad 1.2.10

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentUtils.Monad --version 1.2.10
                    
NuGet\Install-Package FluentUtils.Monad -Version 1.2.10
                    
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="FluentUtils.Monad" Version="1.2.10" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentUtils.Monad" Version="1.2.10" />
                    
Directory.Packages.props
<PackageReference Include="FluentUtils.Monad" />
                    
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 FluentUtils.Monad --version 1.2.10
                    
#r "nuget: FluentUtils.Monad, 1.2.10"
                    
#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 FluentUtils.Monad@1.2.10
                    
#: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=FluentUtils.Monad&version=1.2.10
                    
Install as a Cake Addin
#tool nuget:?package=FluentUtils.Monad&version=1.2.10
                    
Install as a Cake Tool

FluentUtils.Monad

This library contains an implementation of the Result monad as made popular by Rust.

Basic Usage

var okResult = Result.Ok("bob");

// access value of result
okResult.Match(
    value => Console.WriteLine(value),       // "bob"
    err => Console.WriteLine(err.ToString()) // skipped
);

var errResult = Result.Error(new Error(new ErrorCode("1"), new ErrorMessage("No bob")));

errResult.Match(
    value => Console.WriteLine(value),       // skipped
    err => Console.WriteLine(err.ToString()) // "1: Not bob"
);

Async Usage

// synchronous callbacks
string result = await MaybeBob().MatchAsync(
    bob => "bob",
    err => "not bob"
);

// async callbacks
Order result = await CreateOrderAsync().MatchAsync(
    async order => await UpdateOrderAsync(order),
    async err => await ErrorOrderAsync(err)
);

// cancellation support
CancellationTokenSource cts = new CancellationTokenSource();

Order result = await CreateOrderAsync().MatchAsync(
    async (order, ct) => await UpdateOrderAsync(order, ct),
    async (err, ct) => await ErrorOrderAsync(err, ct),
    cts.Token
);
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.

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
3.0.0 128 10/1/2024
3.0.0-PullRequest0030.8 58 10/1/2024
3.0.0-PullRequest0030.7 61 9/30/2024
3.0.0-PullRequest0030.6 61 9/29/2024
2.0.0 126 9/26/2024
2.0.0-PullRequest0028.13 60 9/25/2024
1.3.0-PullRequest0028.12 56 9/25/2024
1.2.17 138 8/6/2024
1.2.16 173 7/21/2024
1.2.15 142 6/29/2024
1.2.14 130 6/19/2024
1.2.13 125 6/19/2024
1.2.12 134 5/7/2024
1.2.10 129 5/5/2024