FluentUtils.Monad 1.2.14

There is a newer version of this package available.
See the version list below for details.
dotnet add package FluentUtils.Monad --version 1.2.14
                    
NuGet\Install-Package FluentUtils.Monad -Version 1.2.14
                    
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.14" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="FluentUtils.Monad" Version="1.2.14" />
                    
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.14
                    
#r "nuget: FluentUtils.Monad, 1.2.14"
                    
#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.14
                    
#: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.14
                    
Install as a Cake Addin
#tool nuget:?package=FluentUtils.Monad&version=1.2.14
                    
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.
  • 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
3.0.0 122 10/1/2024
3.0.0-PullRequest0030.8 52 10/1/2024
3.0.0-PullRequest0030.7 55 9/30/2024
3.0.0-PullRequest0030.6 55 9/29/2024
2.0.0 122 9/26/2024
2.0.0-PullRequest0028.13 54 9/25/2024
1.3.0-PullRequest0028.12 50 9/25/2024
1.2.17 134 8/6/2024
1.2.16 169 7/21/2024
1.2.15 138 6/29/2024
1.2.14 126 6/19/2024
1.2.13 121 6/19/2024
1.2.12 130 5/7/2024
1.2.10 125 5/5/2024