AStarDev.FunctionalParadigm 0.1.4

dotnet add package AStarDev.FunctionalParadigm --version 0.1.4
                    
NuGet\Install-Package AStarDev.FunctionalParadigm -Version 0.1.4
                    
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="AStarDev.FunctionalParadigm" Version="0.1.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AStarDev.FunctionalParadigm" Version="0.1.4" />
                    
Directory.Packages.props
<PackageReference Include="AStarDev.FunctionalParadigm" />
                    
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 AStarDev.FunctionalParadigm --version 0.1.4
                    
#r "nuget: AStarDev.FunctionalParadigm, 0.1.4"
                    
#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 AStarDev.FunctionalParadigm@0.1.4
                    
#: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=AStarDev.FunctionalParadigm&version=0.1.4
                    
Install as a Cake Addin
#tool nuget:?package=AStarDev.FunctionalParadigm&version=0.1.4
                    
Install as a Cake Tool

AStarDev.FunctionalParadigm

Functional programming building blocks for .NET: explicit success/failure, optional values and validation, with no null returns and no exceptions for expected failures.

This package is largely a port of AStar.Dev.Functional.Extensions.

Installation

dotnet add package AStarDev.FunctionalParadigm

All types live in the AStarDev.FunctionalParadigm namespace:

using AStarDev.FunctionalParadigm;

Types

Type Purpose
Result<TResult, TError> An operation that either succeeded (Ok) or failed (Fail) with a typed error.
Option<T> A value that is either present (Some) or absent (None). Use instead of returning null.
Validation<T> Either Valid or Invalid with a list of ValidationErrors, so every problem is reported at once.
Exceptional<T> Wraps code that may throw: Success or Failure carrying the Exception.
Unit A "no value" type for use where a generic type argument is required.

Result

Result<int, string> parsed = int.TryParse(input, out var number)
    ? Result.Success<int, string>(number)
    : Result.Failure<int, string>("Not a number");

string message = parsed
    .Map(value => value * 2)
    .Bind(value => value > 100
        ? Result.Failure<int, string>("Too large")
        : Result.Success<int, string>(value))
    .Match(
        onSuccess: value => $"Result: {value}",
        onFailure: error => $"Error: {error}");

Async chains work directly on Task<Result<,>> and ValueTask<Result<,>>, so there is no need to await into a variable first:

string message = await service.GetAsync(cancellationToken)
    .BindAsync(item => service.EnrichAsync(item))
    .MatchAsync(
        onSuccess: item => Task.FromResult($"Loaded {item}"),
        onFailure: error => Task.FromResult($"Failed: {error}"));

Other helpers include MapAsync, Tap/TapAsync, TapError, OrElseAsync and Ensure/EnsureAsync. RetryExtensions.RetryOnceAsync retries a failed Result operation once.

Option

Option<User> user = Option.Some(currentUser);
Option<User> nobody = Option.None<User>();

string name = user
    .Filter(candidate => candidate.IsActive)
    .Map(candidate => candidate.Name)
    .MapOrDefault(value => value, "Unknown");

Result<User, string> asResult = nobody.ToResult(() => "User not found");

ToOption() converts nullable and reference values, and Values() / Choose(...) filter collections of options.

Validation

Validation<string> name = string.IsNullOrWhiteSpace(input)
    ? Validation.Invalid<string>(new ValidationError("Name", "Name is required"))
    : Validation.Valid(input);

Result<string, string> asResult = name.ToResult(errors => string.Join("; ", errors.Select(error => error.Message)));

Use Apply and Combine to gather the errors from several validations into one result.

Exceptional

Exceptional<string> content = Exceptional.Run(() => File.ReadAllText(path));
Exceptional<string> asyncContent = await Exceptional.RunAsync(() => File.ReadAllTextAsync(path));

Pipe and compose

int length = "hello".Pipe(text => text.ToUpperInvariant()).Pipe(text => text.Length);

Pipe, PipeAsync, Tap and Compose support small, readable pipelines.

Notes

  • Async extension methods use ConfigureAwait(false), so they are safe to call from contexts with a synchronization context.
  • XML documentation ships with the package for IntelliSense.

License

MIT. Source and issues: https://github.com/astar-development/astar-dev-mono/tree/main/packages/core

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

    • No dependencies.

NuGet packages (5)

Showing the top 5 NuGet packages that depend on AStarDev.FunctionalParadigm:

Package Downloads
AStarDev.InfrastructureAppDb

Shared EF Core AppDbContext, entities, configuration and migrations for the AStar OneDrive Sync / Wallpaper Scraper desktop apps.

AStarDev.VelopackPublishingAvalonia

Shared Avalonia update-available dialog, view model, and notification services for AStar Development desktop apps, built on AStar.Dev.Velopack.Publishing.

AStarDev.VelopackPublishing

Shared Velopack update check/download/apply service and options binding used by AStar Development desktop apps.

AStarDev.InfrastructureFilesDb

EF Core persistence models and configuration for scraper and file metadata.

AStarDev.SingleInstance

One running instance per user for AStar Development desktop apps, with a hand-off that brings the running window forward.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.4 220 10/6/2026

v0.1.4 fix(functional-paradigm): remove duplicate README pack item
       v0.1.3 fix(functional-paradigm): remove duplicate README pack item
       v0.1.2 Add README and update ResultExtensions
   v0.1.1 Fix for async extension methods to use ConfigureAwait(false) to avoid deadlocks in certain contexts.
   v0.1.0 Initial release - largely a port of the existing functional programming utilities: AStar.Dev.Functional.Extensions.