Dev.Util.Functional
1.2.2
See the version list below for details.
dotnet add package Dev.Util.Functional --version 1.2.2
NuGet\Install-Package Dev.Util.Functional -Version 1.2.2
<PackageReference Include="Dev.Util.Functional" Version="1.2.2" />
<PackageVersion Include="Dev.Util.Functional" Version="1.2.2" />
<PackageReference Include="Dev.Util.Functional" />
paket add Dev.Util.Functional --version 1.2.2
#r "nuget: Dev.Util.Functional, 1.2.2"
#:package Dev.Util.Functional@1.2.2
#addin nuget:?package=Dev.Util.Functional&version=1.2.2
#tool nuget:?package=Dev.Util.Functional&version=1.2.2
Dev.Util.Functional
Functional programming primitives for C#. This package introduces Result<T> and Option<T> patterns to help you write cleaner, exception-free, and safer code.
📦 Installation
dotnet add package Dev.Util.Functional
✨ Features
- ✅ Result Pattern: Explicit Success/Failure returns instead of throwing exceptions.
- ❓ Option/Maybe Type: Safe null handling without the risk of
NullReferenceException. - ⛓️ Fluent Transformations:
Map,Bind,OnSuccess, andMatchfor clean orchestration. - 🛠️ Interop: Easily convert between
Result<T>andOption<T>.
🛠 Usage Examples
1. The Result Pattern
Stop using "magic values" or exceptions for expected business logic failures.
using Dev.Util.Functional;
public Result<User> GetUser(int id)
{
var user = _db.Find(id);
if (user == null) return Result.Fail<User>("User not found");
return Result.Ok(user);
}
// Consuming the result
var result = GetUser(1);
if (result.IsSuccess)
{
Process(result.Value);
}
2. Fluent Railway Chaining
Chain operations that only execute if the previous step succeeded.
using Dev.Util.Functional;
var result = GetUser(1)
.OnSuccess(user => ValidatePermissions(user))
.OnSuccess(user => LogAccess(user))
.Match(
onSuccess: user => "Welcome " + user.Name,
onFailure: error => "Error: " + error
);
3. Safe Null Handling with Option
Enforce the check for presence/absence of a value.
using Dev.Util.Functional;
Option<string> middleName = GetMiddleName();
// Safe extraction
string display = middleName.ValueOr("N/A");
// Functional access
middleName.IfSome(name => Console.WriteLine(name));
4. Mapping Results
Transform the data inside a result while preserving the execution state.
using Dev.Util.Functional;
Result<int> score = GetScore();
Result<string> grade = score.Map(s => s > 50 ? "Pass" : "Fail");
Use Dev.Util.Functional when you want to make "Edge Cases" first-class citizens in your API design.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 is compatible. 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 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 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Dev.Util.Functional:
| Package | Downloads |
|---|---|
|
Dev.Util
The complete Dev.Util ecosystem for .NET. One package to rule them all. Provides access to Core, Collections, IO, Security, Web, Reflection, Tasks, and Json modules. |
GitHub repositories
This package is not used by any popular GitHub repositories.