Jds.LanguageExt.Extras 0.1.0

There is a newer version of this package available.
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
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="Jds.LanguageExt.Extras" Version="0.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jds.LanguageExt.Extras --version 0.1.0
#r "nuget: Jds.LanguageExt.Extras, 0.1.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 Jds.LanguageExt.Extras as a Cake Addin
#addin nuget:?package=Jds.LanguageExt.Extras&version=0.1.0

// Install Jds.LanguageExt.Extras as a Cake Tool
#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 returns true, the existing value is returned. If it returns false, then it executes onFalse to create a TLeft.
  • Either<TLeft, TRight>.FilterAsync<TLeft, TRight>(Func<TRight, Task<bool>> filter, Func<TRight, TLeft> onFalse)
    • Filters right values by executing filter. If it returns true, the existing value is returned. If it returns false, then it executes onFalse to create a TLeft.
  • Either<TLeft, TRight>.FilterAsync<TLeft, TRight>(Func<TRight, Task<bool>> filter, Func<TRight, Task<TLeft>> onFalse)
    • Filters right values by executing filter. If it returns true, the existing value is returned. If it returns false, then it executes onFalse to create a TLeft.
  • 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.
  • 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.
  • 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.
  • Either<TLeft, TRight>.ToResult<TLeft, TRight>(Func<TLeft, Exception> ifLeft)
    • Converts the Either<TLeft, TRight> into a Result<TRight>.
  • Either<TLeft, TRight>.ToResult<TLeft, TRight>() where TLeft : Exception
    • Converts the Either<TLeft, TRight> into a Result<TRight>.

Result<TSuccess> Extensions

  • Result<TSuccess>.Bind<TSuccess, TNewSuccess>(Func<TSuccess, Result<TNewSuccess>> func)
    • Executes func, which returns Result<TNewSuccess>, when the result is a success.
  • Result<TSuccess>.BindAsync<TSuccess, TNewSuccess>(Func<TSuccess, Task<Result<TNewSuccess>>> func)
    • Executes func, which returns Task<Result<TNewSuccess>>, when the result is a success.
  • Result<TSuccess>.Filter<TSuccess>(Func<TSuccess, bool> filter, Func<TSuccess, Exception> onFalse)
    • Filters TSuccess values by executing filter. If it returns true, the existing value is returned. If it returns false, then it executes onFalse to create an Exception.
  • Result<TSuccess>.FilterAsync<TSuccess>(Func<TSuccess, Task<bool>> filter, Func<TSuccess, Exception> onFalse)
    • Filters TSuccess values by executing filter. If it returns true, the existing value is returned. If it returns false, then it executes onFalse to create an Exception.
  • Result<TSuccess>.FilterAsync<TSuccess>(Func<TSuccess, Task<bool>> filter, Func<TSuccess, Task<Exception>> onFalse)
    • Filters TSuccess values by executing filter. If it returns true, the existing value is returned. If it returns false, then it executes onFalse to create an Exception.
  • Result<TSucess>.IfFailThrow<TSuccess>()
    • Throws an InvalidOperationException if the Result<TSucess> is an Exception, returning TSuccess upon success.
  • 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.
  • 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.
  • 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.
  • Result<TSuccess>.ToEither<TSuccess>()
    • Converts the Result<TSuccess> into an Either<Exception, TSuccess>.
Product 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. 
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
1.0.0 94 5/21/2024
0.6.0 1,318 12/4/2022
0.5.0 1,148 6/11/2022
0.4.0 520 6/10/2022
0.3.0 2,458 4/5/2022
0.2.0 503 3/2/2022
0.1.0 387 3/1/2022