Skip to content

moonad-dotnet/moonad.next

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moonad.Next

A simple F#'s pipe-forward operator port for C#. This lib is part of the Moonad project.

Version Tests Nuget

Installing

The project's package can be found on Nuget and installed by your IDE or shell as following:

dotnet add package Moonad.Next

or

PM> Install-Package Moonad.Next

Pipe-forward

The 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}"); //16

Example 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

About

A simple pipe-forward operator for C#

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages