Emik.Results
3.0.1
See the version list below for details.
dotnet add package Emik.Results --version 3.0.1
NuGet\Install-Package Emik.Results -Version 3.0.1
<PackageReference Include="Emik.Results" Version="3.0.1" />
paket add Emik.Results --version 3.0.1
#r "nuget: Emik.Results, 3.0.1"
// Install Emik.Results as a Cake Addin #addin nuget:?package=Emik.Results&version=3.0.1 // Install Emik.Results as a Cake Tool #tool nuget:?package=Emik.Results&version=3.0.1
Emik.Results
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.
Examples
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.
Contribute
Issues and pull requests are welcome to help this repository be the best it can be.
License
This repository falls under the MPL-2 license.
Product | Versions 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. |
-
.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 |
---|---|
Emik.Unions
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 | 138 | 3/7/2024 |
3.0.1 | 171 | 1/3/2024 |
3.0.0 | 115 | 1/3/2024 |
2.1.1 | 700 | 6/5/2023 |
2.1.0 | 160 | 6/5/2023 |
2.0.1 | 973 | 5/16/2023 |
2.0.0 | 651 | 5/14/2023 |
1.3.1 | 164 | 5/8/2023 |
1.3.0 | 163 | 5/8/2023 |
1.2.0 | 985 | 5/7/2023 |
1.1.2 | 173 | 5/7/2023 |
1.1.1 | 177 | 5/4/2023 |
1.1.0 | 1,386 | 5/4/2023 |
1.0.5 | 744 | 3/14/2023 |
1.0.4 | 315 | 1/19/2023 |
1.0.3 | 928 | 1/14/2023 |
1.0.2 | 880 | 1/13/2023 |
1.0.1 | 290 | 1/12/2023 |
1.0.0 | 879 | 1/9/2023 |