SoftwareMadeSimple.SimpleResults.Functional 1.0.0

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

SimpleResults.Functional

NuGet License: MIT

Functional applicative extensions for SoftwareMadeSimple.SimpleResults, providing Lift and Apply with error accumulation.

Installation

dotnet add package SoftwareMadeSimple.SimpleResults.Functional

Why?

When validating multiple fields independently, you typically want to collect all errors rather than short-circuiting on the first failure. The applicative pattern enables exactly this � validate each field separately, then combine the results while accumulating every error.

Usage

Lift & Apply

Use Lift to wrap a function into a Result, then chain Apply calls to feed in each validated argument. If any argument fails, all errors are accumulated.

using SoftwareMadeSimple.SimpleResults;
using SoftwareMadeSimple.SimpleResults.Functional;

record Person(string Name, int Age);

Result<string, ValidationErrors> nameResult = ValidateName(input.Name);
Result<int, ValidationErrors> ageResult = ValidateAge(input.Age);

var result =
    LiftResult<ValidationErrors>
        .Lift((string name, int age) => new Person(name, age))
        .Apply(nameResult)
        .Apply(ageResult);

if (result.IsSuccess)
{
    Person person = result.Value;
    // use person
}
else
{
    IEnumerable<ValidationError> errors = result.Error;
    // all validation errors are collected here
}

Error accumulation

Unlike monadic Bind (which short-circuits on the first error), Apply runs every validation and collects all failures:

Result<string, ValidationErrors> nameResult = new List<ValidationError>
{
    new("Name is required"),
    new("Name must be at least 2 characters")
};

Result<int, ValidationErrors> ageResult = new List<ValidationError>
{
    new("Age must be positive")
};

var result =
    LiftResult<ValidationErrors>
        .Lift((string name, int age) => new Person(name, age))
        .Apply(nameResult)
        .Apply(ageResult);

// result.Error contains all 3 validation errors

Functions with more parameters

Lift supports functions with up to 16 parameters. Each additional parameter is applied with another .Apply() call:

record Address(string Street, string City, string Zip);

var result =
    LiftResult<ValidationErrors>
        .Lift((string street, string city, string zip) => new Address(street, city, zip))
        .Apply(streetResult)
        .Apply(cityResult)
        .Apply(zipResult);

Requirements

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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.

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.3.0 102 5/15/2026
1.2.0 149 4/3/2026
1.1.0 119 3/17/2026
1.0.1 110 3/12/2026
1.0.0 104 3/12/2026