Jds.LanguageExt.Extras
0.1.0
See the version list below for details.
dotnet add package Jds.LanguageExt.Extras --version 0.1.0
NuGet\Install-Package Jds.LanguageExt.Extras -Version 0.1.0
<PackageReference Include="Jds.LanguageExt.Extras" Version="0.1.0" />
<PackageVersion Include="Jds.LanguageExt.Extras" Version="0.1.0" />
<PackageReference Include="Jds.LanguageExt.Extras" />
paket add Jds.LanguageExt.Extras --version 0.1.0
#r "nuget: Jds.LanguageExt.Extras, 0.1.0"
#:package Jds.LanguageExt.Extras@0.1.0
#addin nuget:?package=Jds.LanguageExt.Extras&version=0.1.0
#tool nuget:?package=Jds.LanguageExt.Extras&version=0.1.0
LanguageExt.Extras
A collection of extension methods and helpers which extend the use of LanguageExt.
This project is not affiliated with LanguageExt and asserts no claims upon its intellectual property.
Installation
Install LanguageExt.Extras as a NuGet package, via an IDE package manager, or using the command-line instructions at nuget.org.
Use / API
Using Statements
LanguageExt.Extras extends existing LanguageExt types. As such, you'll need both LanguageExt and LanguageExt.Extras in scope.
All API examples shown below assume the following using statements:
using LanguageExt;
using LanguageExt.Common;
using Jds.LanguageExt.Extras;
Either<TLeft, TRight> Extensions
Either<TLeft, TRight>.Filter<TLeft, TRight>(Func<TRight, bool> filter, Func<TRight, TLeft> onFalse)- Filters right values by executing
filter. If it returnstrue, the existing value is returned. If it returnsfalse, then it executesonFalseto create aTLeft.
- Filters right values by executing
Either<TLeft, TRight>.FilterAsync<TLeft, TRight>(Func<TRight, Task<bool>> filter, Func<TRight, TLeft> onFalse)- Filters right values by executing
filter. If it returnstrue, the existing value is returned. If it returnsfalse, then it executesonFalseto create aTLeft.
- Filters right values by executing
Either<TLeft, TRight>.FilterAsync<TLeft, TRight>(Func<TRight, Task<bool>> filter, Func<TRight, Task<TLeft>> onFalse)- Filters right values by executing
filter. If it returnstrue, the existing value is returned. If it returnsfalse, then it executesonFalseto create aTLeft.
- Filters right values by executing
Either<TLeft, TRight>.Tap<TLeft, TRight>(Action<TRight> onRight, Action<TLeft> onLeft)- Executes a side effect, e.g., logging, based upon the state of the either. The current value is returned unchanged.
Either<TLeft, TRight>.TapAsync<TLeft, TRight>(Func<TRight, Task> onSuccess, Func<TLeft, Task> onFailure)- Executes an asynchronous side effect, e.g., dispatching a status notification via
HttpClient, based upon the state of the either. The current value is returned unchanged.
- Executes an asynchronous side effect, e.g., dispatching a status notification via
Either<TLeft, TRight>.TapLeft<TLeft, TRight>(Action<TLeft> onFailure)- Executes a side effect, e.g., logging, when the either is a left. The current value is returned unchanged.
Either<TLeft, TRight>.TapLeftAsync<TLeft, TRight>(Func<TLeft, Task> onFailure)- Executes an asynchronous side effect, e.g., dispatching a status notification via
HttpClient, when the either is a left. The current value is returned unchanged.
- Executes an asynchronous side effect, e.g., dispatching a status notification via
Either<TLeft, TRight>.TapRight<TLeft, TRight>(Action<TRight> onSuccess)- Executes a side effect, e.g., logging, when the either is a right. The current value is returned unchanged.
Either<TLeft, TRight>.TapRightAsync<TLeft, TRight>(Func<TRight, Task> onSuccess)- Executes an asynchronous side effect, e.g., dispatching a status notification via
HttpClient, when the either is a right. The current value is returned unchanged.
- Executes an asynchronous side effect, e.g., dispatching a status notification via
Either<TLeft, TRight>.ToResult<TLeft, TRight>(Func<TLeft, Exception> ifLeft)- Converts the
Either<TLeft, TRight>into aResult<TRight>.
- Converts the
Either<TLeft, TRight>.ToResult<TLeft, TRight>() where TLeft : Exception- Converts the
Either<TLeft, TRight>into aResult<TRight>.
- Converts the
Result<TSuccess> Extensions
Result<TSuccess>.Bind<TSuccess, TNewSuccess>(Func<TSuccess, Result<TNewSuccess>> func)- Executes
func, which returnsResult<TNewSuccess>, when the result is a success.
- Executes
Result<TSuccess>.BindAsync<TSuccess, TNewSuccess>(Func<TSuccess, Task<Result<TNewSuccess>>> func)- Executes
func, which returnsTask<Result<TNewSuccess>>, when the result is a success.
- Executes
Result<TSuccess>.Filter<TSuccess>(Func<TSuccess, bool> filter, Func<TSuccess, Exception> onFalse)- Filters
TSuccessvalues by executingfilter. If it returnstrue, the existing value is returned. If it returnsfalse, then it executesonFalseto create anException.
- Filters
Result<TSuccess>.FilterAsync<TSuccess>(Func<TSuccess, Task<bool>> filter, Func<TSuccess, Exception> onFalse)- Filters
TSuccessvalues by executingfilter. If it returnstrue, the existing value is returned. If it returnsfalse, then it executesonFalseto create anException.
- Filters
Result<TSuccess>.FilterAsync<TSuccess>(Func<TSuccess, Task<bool>> filter, Func<TSuccess, Task<Exception>> onFalse)- Filters
TSuccessvalues by executingfilter. If it returnstrue, the existing value is returned. If it returnsfalse, then it executesonFalseto create anException.
- Filters
Result<TSucess>.IfFailThrow<TSuccess>()- Throws an
InvalidOperationExceptionif theResult<TSucess>is anException, returningTSuccessupon success.
- Throws an
Result<TSuccess>.Tap<TSuccess>(Action<TSuccess> onSuccess, Action<Exception> onFailure)- Executes a side effect, e.g., logging, based upon the state of the result. The current value is returned unchanged.
Result<TSuccess>.TapAsync<TSuccess>(Func<TSuccess, Task> onSuccess, Func<Exception, Task> onFailure)- Executes an asynchronous side effect, e.g., dispatching a status notification via
HttpClient, based upon the state of the result. The current value is returned unchanged.
- Executes an asynchronous side effect, e.g., dispatching a status notification via
Result<TSuccess>.TapFailure<TSuccess>(Action<Exception> onFailure)- Executes a side effect, e.g., logging, when the result is a failure. The current value is returned unchanged.
Result<TSuccess>.TapFailureAsync<TSuccess>(Func<Exception, Task> onFailure)- Executes an asynchronous side effect, e.g., dispatching a status notification via
HttpClient, when the result is a failure. The current value is returned unchanged.
- Executes an asynchronous side effect, e.g., dispatching a status notification via
Result<TSuccess>.TapSuccess<TSuccess>(Action<TSuccess> onSuccess)- Executes a side effect, e.g., logging, when the result is a success. The current value is returned unchanged.
Result<TSuccess>.TapSuccessAsync<TSuccess>(Func<TSuccess, Task> onSuccess)- Executes an asynchronous side effect, e.g., dispatching a status notification via
HttpClient, when the result is a success. The current value is returned unchanged.
- Executes an asynchronous side effect, e.g., dispatching a status notification via
Result<TSuccess>.ToEither<TSuccess>()- Converts the
Result<TSuccess>into anEither<Exception, TSuccess>.
- Converts the
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 was computed. 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. 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. |
-
net6.0
- LanguageExt.Core (>= 4.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.