Compze.Functional 0.6.0

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

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.

Package Description
Compze.Contracts Design-by-contract assertions, including the _assert() pipeline operator

License

Apache-2.0

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .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