Emik.Results 3.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Emik.Results --version 3.0.0                
NuGet\Install-Package Emik.Results -Version 3.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="Emik.Results" Version="3.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Emik.Results --version 3.0.0                
#r "nuget: Emik.Results, 3.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.
// Install Emik.Results as a Cake Addin
#addin nuget:?package=Emik.Results&version=3.0.0

// Install Emik.Results as a Cake Tool
#tool nuget:?package=Emik.Results&version=3.0.0                


NuGet package License

Result<TOk, TErr> is the type used for returning and propagating errors. It is either Ok, representing success and containing a value, or Err, representing error and containing an error value.

This project has a dependency to Emik.Morsels, if you are building this project, refer to its README first.


using System;
using System.Linq;
using Emik.Results;
using static Emik.Results.Please;

T Throw<T>(T unused) => throw new();

// Turn try-catch into a Result, and/or use operators to transform them.
Result<string, Exception> fail = "foo" & Try(Throw, "bar");

// 'IsErr' guarantees each variant be non-null in their appropriate branches.
string value = fail.IsErr ? fail.Err.Message : fail.Ok;

// You can also use the out parameter variant.
value = fail.Out(out var str, out var exception) ? str : exception.Message;

// Implements 'IEnumerable<T>', allowing for LINQ usage.
int length = fail.Select(x => x.Length).ToArray();

// Implements 'ISet<T>' as well, allowing for quering of other 'IEnumerable<T>' instances.
var thisIsTrue = Result.Ok(2).IsSupersetOf([2]);
using System;
using System.Threading.Tasks;
using Emik.Results.Extensions;
using static Emik.Results.Result;

// Works with Tasks and ValueTasks too.
Result<int, Exception> success = await Task<int>.FromResult(10).Try();

// Works with Lazy.
Result<int, Exception> failure = new Lazy<int>(() => throw new()).Try();

// Convert nullable value types into Result.
Result<int, object> none = default(int?).IntoOk();

// Convert nullable reference types into Result.
Result<string, object> some = "".IntoOk();

// Filter and map.
var thisIsAlsoTrue = Err(2).MapErr(x => new List<int>(x)).IsErrAnd(x => x is { Capacity: 2, Count: 0 });

For a list of APIs, click here.


Issues and pull requests are welcome to help this repository be the best it can be.


This repository falls under the MPL-2 license.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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 is compatible.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 is compatible.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net20 is compatible.  net35 is compatible.  net40 is compatible.  net403 was computed.  net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 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.
  • .NETFramework 2.0

    • No dependencies.
  • .NETFramework 3.5

    • No dependencies.
  • .NETFramework 4.0

    • No dependencies.
  • .NETStandard 1.0

    • No dependencies.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net5.0

    • No dependencies.
  • net7.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Emik.Results:

Package Downloads

Contains the functional programming paradigm; unions in both disjointed- and tagged flavors.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
4.0.0 109 3/7/2024
3.0.1 150 1/3/2024
3.0.0 90 1/3/2024
2.1.1 662 6/5/2023
2.1.0 139 6/5/2023
2.0.1 925 5/16/2023
2.0.0 618 5/14/2023
1.3.1 142 5/8/2023
1.3.0 144 5/8/2023
1.2.0 947 5/7/2023
1.1.2 147 5/7/2023
1.1.1 149 5/4/2023
1.1.0 1,326 5/4/2023
1.0.5 715 3/14/2023
1.0.4 291 1/19/2023
1.0.3 889 1/14/2023
1.0.2 839 1/13/2023
1.0.1 267 1/12/2023
1.0.0 837 1/9/2023