D20Tek.Functional
1.1.9
dotnet add package D20Tek.Functional --version 1.1.9
NuGet\Install-Package D20Tek.Functional -Version 1.1.9
<PackageReference Include="D20Tek.Functional" Version="1.1.9" />
<PackageVersion Include="D20Tek.Functional" Version="1.1.9" />
<PackageReference Include="D20Tek.Functional" />
paket add D20Tek.Functional --version 1.1.9
#r "nuget: D20Tek.Functional, 1.1.9"
#:package D20Tek.Functional@1.1.9
#addin nuget:?package=D20Tek.Functional&version=1.1.9
#tool nuget:?package=D20Tek.Functional&version=1.1.9
Functionally
Introduction
Welcome to the Functionally code library (aka D20Tek.Functional), this package contains a set of classes that improve the functional programming experience in C#. I based many of the library classes and api on F#'s functional capabilities to ensure smooth usage between the two: classes like Option, Result, and Choice; and methods like Iter, Bind, and Map. I took inspiration for this library (and a couple of the sample games - ChutesAndLadders and MartianTrail) from "Functional Programming in C#" by Simon J Painter (https://github.com/madSimonJ/FunctionalProgrammingWithCSharp).
I added the D20Tek.Functional.AspNetCore library to this project as well. It wraps some common functionality to transform Result<T> objects into appropriate service endpoint responses, or ProblemDetails for errors that occur. This library removes a lot of repetitive code for dealing with results in WebApi development. It's a separate package to minimize dependencies on the base package, and only add that overhead if you need to integrate with ASP.NET.
As of the first version, I did not provide extension methods for arrays, lists, or enumerables that extend the same functional methods (like Iter, Bind, Map, etc). Enumerables in C# already follow a functional paradigm using LINQ, so I didn't want to add confusion by adding methods that do similar things, but with different names. If I get feedback requests to provide those as well, then I will look at incorporating an extension layer on IEnumerables.
There is also an extensive set of sample console applications and simple games that show how to use this package.
Installation
This library is a NuGet package so it is easy to add to your project. To install the package into your solution, you can use the NuGet Package Manager. In PM, please use the following command:
PM > Install-Package D20Tek.Functional -Version 1.1.9
PM > Install-Package D20Tek.Functional.AspNetCore -Version 1.1.9
To install in the Visual Studio UI, go to the Tools menu > "Manage NuGet Packages". Then search for D20Tek.Functional, and install whichever packages you require from there.
Usage
Once you've installed the NuGet package, you can start using it in your .NET projects.
Code examples are in the samples folder of this repository.
Unit type
Use the Unit type when a Result<T> represents a side-effect-only operation that has no meaningful return value. Because C# generics can't use void as a type argument, Result<Unit> lets you model "succeeded with nothing to return" without inventing a dummy value:
Result<Unit> SaveChanges()
{
// ... perform the side effect ...
return Result.Success(); // successful Result<Unit>
// return Result.Failure(error); // failed Result<Unit>
}
Samples
Feedback
If you use these libraries and have any feedback, bugs, or suggestions, please file them in the Issues section of this repository. I'm still in the process of building these libraries and samples, so any suggestions that would make it more useable are welcome.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. 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 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. |
-
net10.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (6)
Showing the top 5 NuGet packages that depend on D20Tek.Functional:
| Package | Downloads |
|---|---|
|
D20Tek.Functional.AspNetCore
Welcome to the Functionally code library, this package contains a set of classes that improve the functional programming experience in C#. I based many of the library classes and api on F#'s functional capabilities to ensure smooth usage between the two: classes like Option, Result, and Choice; and methods like Iter, Bind, and Map. The extensions for ASP.NET Core add functionality to working with controller-based webapi and minimal webapi. Making it easier to convert Result<T> into service endpoint responses. |
|
|
LowDb.Net.Repositories
A .NET implementation of the LowDB file-based database for use in applications and experiments that only require a minimal database implementation. Supports JSON-based database in web storage. This extension provides the Repository pattern over a LowDb database. |
|
|
D20Tek.Mediator
A minimal implementation of the Mediator pattern that can be used in any .NET project, with particular focus on usage in WebApi |
|
|
D20Tek.BlazorComponents.All
A convenience meta-package that bundles all of the D20Tek Blazor component packages (Functionally, Markdown, Modal, Spinner, Timer, Toast, TogglePanel, ToggleSwitch). Install this to get the full component suite in one reference. If you only need a few components, install the individual packages instead. |
|
|
D20Tek.BlazorComponents.Functionally
Blazor UI components that map D20Tek.Functional concepts (Result/Error) into your user interface. Includes ResultValidator (form validation mapping), ResultAlert (inline success/error banner), ResultView (state-based render branching), and ResultToast (service-based notifications). Each has a default layout and color scheme that can be customized for your application. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.1.9 | 38 | 9/11/2026 |
| 1.1.7 | 141 | 8/29/2026 |
| 1.1.6 | 209 | 8/11/2026 |
| 1.1.5 | 179 | 6/10/2026 |
| 1.1.4 | 212 | 4/26/2026 |
| 1.1.3 | 179 | 3/27/2026 |
| 1.1.2 | 195 | 2/13/2026 |
| 1.1.0 | 234 | 1/9/2026 |
| 1.0.6 | 333 | 11/27/2025 |
| 1.0.2 | 410 | 9/19/2025 |
| 1.0.1 | 361 | 8/6/2025 |
| 0.9.17 | 152 | 8/2/2025 |
| 0.9.16 | 216 | 7/5/2025 |
| 0.9.15 | 445 | 5/15/2025 |
| 0.9.14 | 318 | 5/7/2025 |
| 0.9.12 | 281 | 5/7/2025 |
| 0.9.11 | 190 | 5/2/2025 |
| 0.9.10 | 463 | 3/11/2025 |
| 0.9.8 | 319 | 3/11/2025 |
| 0.9.7 | 316 | 3/11/2025 |
Initial version with basic functional programming helper classes and extension methods. Replaced Option<T> class with Optional<T> for fewer naming conflicts in .NET.