Compze.Functional
0.6.0
dotnet add package Compze.Functional --version 0.6.0
NuGet\Install-Package Compze.Functional -Version 0.6.0
<PackageReference Include="Compze.Functional" Version="0.6.0" />
<PackageVersion Include="Compze.Functional" Version="0.6.0" />
<PackageReference Include="Compze.Functional" />
paket add Compze.Functional --version 0.6.0
#r "nuget: Compze.Functional, 0.6.0"
#:package Compze.Functional@0.6.0
#addin nuget:?package=Compze.Functional&version=0.6.0
#tool nuget:?package=Compze.Functional&version=0.6.0
Compze.Functional
Code that reads the way you would describe the algorithm in words, not code that must be read inside out. Powered by the pipe forward operator and friends.
Sometimes very little goes a very long way. With just a handful of trivially simple extension methods we enable you to write code like this:
public OperationResult SomeBusinessMethod(Guid userId) =>
userId
._(LoadFromDatabase)
._tap(it => { /*log*/ })
._assert(MayExecuteThisOperation)
._(ActualOperationLogic)
._tap(it => { /*log*/ })
._assert(ResultIsWhatWeExpected);
Pipe forward operator
Chain operations fluently with ._():
var result = initialValue
._(Transform)
._(Validate)
._(Format);
Primary methods:
_tap()— execute side effect, return original value_mutate()— intent declaring alias for _tap_then()— discard the current value and continue with a new one. Enables one-liner implementations when the previous value is irrelevant.
Note: The
_assert()method used in the examples above comes from Compze.Contracts — you may want to check it out.
The Unit type
Like void but without splitting Action<T> from Func<T,T2>
In .NET Action<T> and Func<T, T2> are not compatible, resulting in tons of code needing one version for action and one for Func. Unit is the solution. Methods with no meaningful return value return unit removing incompatibility since unit is a value, a single uniform value.
Painlessly convert void methods to unit returning methods that will participate frictionlessly in piping:
public unit Log(string message) => unit.From(() => Console.WriteLine(message));
Convert between Action<T> and Func<T,unit>
Action anAction = SomeVoidMethod;
Func<unit> aUnitFunc = anAction.AsFunc();
var anotherAction = aUnitFunc.AsAction();
var something = AMethodTakingAFunc(unit.Func(SomeVoidMethod));
What's with the naming?
These extensions apply to every type, so name collisions and polluting auto-complete lists are a very real concern. _camelCase provides:
- Near zero collision risk — no standard .NET method starts with
_. - Clear visuals — instantly recognizable as something other than regular methods.
- Great discoverability — type
._and all these extensions are right there grouped together.
._( as the pipeline operator has the same advantages and keeps something you will be using constantly as short as possible.
Lower case unit is sort of a wish for the future and the way we think it should be. We hope our unit will eventually be replaced by a language keyword and built in type.
Related packages
| Package | Description |
|---|---|
| Compze.Contracts | Design-by-contract assertions, including the _assert() pipeline operator |
License
Apache-2.0
| 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 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. |
| .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.
NuGet packages (14)
Showing the top 5 NuGet packages that depend on Compze.Functional:
| Package | Downloads |
|---|---|
|
Compze.Utilities.Testing.Must
Fluent assertion library for Compze testing. |
|
|
Compze.Utilities.SystemCE.ThreadingCE
Package Description |
|
|
Compze.Utilities.Testing.XUnit
xUnit testing utilities and attributes for the Compze framework. |
|
|
Compze.Utilities.DependencyInjection
Package Description |
|
|
Compze.Utilities.Logging
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.6.0 | 147 | 2/28/2026 |