Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.47 KB

README.md

File metadata and controls

52 lines (38 loc) · 1.47 KB

Bebop.Monads

This project provides the following monads:

  • Maybe
  • Try

This library is:

  • netstandard2.0
  • strong-name signed
  • CLS compliant

NuGet Build status Coverage Status

Maybe

This represents the Maybe (or Option) monad.

var m = Maybe.From("these pretzels are making me thirsty");
var n = Maybe.Nothing<int>(); 

var x = m.OrElse("yada yada yada"); // yields "these pretzels ..."
var y = n.OrElse(17); // yields 17

See full documentation for Maybe;

Try

This represents an exceptional monad that can be used to construct lazy chains of action and catch blocks.

var result = await Try
    .Do(() => "I will succeed.")
    .ThenAsync(async x => x + " Oh will you?")
    .Then(_ => throw new InvalidOperationException())
    .Catch<InvalidOperationException>(ex => 
    {
        Log.WriteError("Operation did not succeed");
        return "failed";
    });

See full documentation for Try;

Unit

This represents the functional unit type.

var u = default(Unit);

See full documentation for Unit;