ARPL 1.0.1

There is a newer version of this package available.
See the version list below for details.
dotnet add package ARPL --version 1.0.1
                    
NuGet\Install-Package ARPL -Version 1.0.1
                    
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="ARPL" Version="1.0.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ARPL" Version="1.0.1" />
                    
Directory.Packages.props
<PackageReference Include="ARPL" />
                    
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 ARPL --version 1.0.1
                    
#r "nuget: ARPL, 1.0.1"
                    
#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 ARPL@1.0.1
                    
#: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=ARPL&version=1.0.1
                    
Install as a Cake Addin
#tool nuget:?package=ARPL&version=1.0.1
                    
Install as a Cake Tool

ARPL (Advanced Result Pattern Library)

A lightweight C# library providing robust discriminated unions for error handling and functional programming patterns. ARPL offers two main types: Either<L,R> for generic discriminated unions and SResult<R> for specialized success/error handling.

Features 🚀

  • Either<L,R> - A generic discriminated union that can hold one of two possible types
  • SResult<R> - A specialized result type for handling success/error scenarios
  • Implicit conversions between Either<Error,R> and SResult<R>
  • Pattern matching support for elegant value handling
  • Type-safe error handling without exceptions
  • Functional programming friendly design

Getting Started 🏃

Installation

# Package installation coming soon

Basic Usage

Using Either<L,R>
// Create Either instances
Either<string, int> leftValue = Either<string, int>.Left("error message");
Either<string, int> rightValue = Either<string, int>.Right(42);

// Pattern match to handle both cases
leftValue.Match(
    left => Console.WriteLine($"Left value: {left}"),
    right => Console.WriteLine($"Right value: {right}"));
Using SResult<R>
// Create success result
SResult<int> success = SResult<int>.Success(42);

// Create error result
SResult<int> error = SResult<int>.Error(new Error("Something went wrong"));

// Check result type
if (success.IsSuccess)
    Console.WriteLine($"Success value: {success.SuccessValue}");
if (error.IsFail)
    Console.WriteLine($"Error value: {error.ErrorValue}");

Type Features

Either<L,R>

  • Left(L value) - Creates a new Either instance containing a left value
  • Right(R value) - Creates a new Either instance containing a right value
  • IsLeft - Indicates if the instance contains a left value
  • IsRight - Indicates if the instance contains a right value
  • Match - Pattern matching for transforming or handling the contained value

SResult<R>

  • Success(R value) - Creates a new success result
  • Error(Error value) - Creates a new error result
  • IsSuccess - Indicates if the result represents success
  • IsFail - Indicates if the result represents an error
  • SuccessValue - Gets the success value
  • ErrorValue - Gets the error value

Implicit Conversions

ARPL supports implicit conversions between Either<Error,R> and SResult<R>, making it seamless to work with both types:

// Convert from Either to SResult
Either<Error, int> either = Either<Error, int>.Right(42);
SResult<int> result = either; // Implicit conversion

// Convert from SResult to Either
SResult<int> sresult = SResult<int>.Success(42);
Either<Error, int> converted = sresult; // Implicit conversion

Best Practices

  1. Use Either<L,R> when you need a generic discriminated union
  2. Use SResult<R> for specific success/error handling scenarios
  3. Leverage pattern matching with Match for clean and safe value handling
  4. Prefer using the type system for error handling instead of exceptions

Contributing 🤝

Contributions are welcome! Feel free to submit issues and pull requests.

License 📄

This project is licensed under the MIT License - see the LICENSE file for details.

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.  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.
  • net6.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on ARPL:

Package Downloads
ARPL.AspNetCore

A lightweight C# library providing robust discriminated unions for error handling and functional programming patterns. ARPL offers two main types: Either<L,R> for generic discriminated unions and SResult<R> for specialized success/error handling.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.12 42 9/28/2025
1.0.11 116 9/13/2025
1.0.10 152 5/2/2025
1.0.9 162 5/1/2025
1.0.8 184 4/30/2025
1.0.7 166 4/30/2025
1.0.6 171 4/29/2025
1.0.5 106 4/26/2025
1.0.5-rc 165 4/25/2025
1.0.4 169 4/25/2025
1.0.3 177 4/24/2025
1.0.2 121 4/19/2025
1.0.1 215 4/16/2025
1.0.0 228 4/15/2025