A simple F#'s pipe-forward operator port for C#. This lib is part of the Moonad project.
The project's package can be found on Nuget and installed by your IDE or shell as following:
dotnet add package Moonad.Nextor
PM> Install-Package Moonad.NextThe pipe-forward operator offers a way to chain methods passing the result of the prior to the next as the first parameter.
Example 1 - Sync:
10.Next(i => i + 10)
.Next(i => $"Total: {i}")
.Next(s => Console.WriteLine(s)); //"Total: 20"Example 2 - Async:
10.Next(i => i * 10)
.Next(async i => await Task.FromResult($"Total: {i}"))
.Next(s => Console.WriteLine(s)); //"Total: 100"Example 3 - Tuple<T1, T2>:
(8, 2).Next((x, y) => x * y)
.Next((i) => $"Sum result: {i}"); //16Example 4 - Tuple<T1, T2, T3>:
(1, 3, 5).Next((x, y, z) => (x + y, z))
.Next((x, y) => x * y)
.Next(x => Math.Pow(x, 2)); //400