Skip to main content
ActiveC#Open SourceFunctional Programming

SharpMonads.Core

A lightweight monads library for .NET: Option, Result, Either and Unit as readonly record struct, with their laws verified and zero dependencies. Born from DevSweep and distilled into a NuGet package.

SharpMonads.Core is a lightweight monads library for .NET, distilled from the domain of DevSweep. It makes null and errors explicit in the type system, without converting your whole project to functional programming.

What's inside

  • Option<T> — a value that may or may not be there, without null.

  • Result<TValue, TError> — operations that can fail, with the error in the signature.

  • Either<TLeft, TRight> — two possible types, right-biased.

  • Unit — the "void" you can actually compose.

Why

  • **readonly record struct**: functional composition with no garbage-collector pressure.

  • Verified laws: the three monad laws tested with TUnit.

  • LINQ sugar: from ... select over any monad.

  • Zero dependencies and idiomatic C#.

Installation

bash
dotnet add package SharpMonads.Core

Statistics

Last commit
2026-06-14
License
MIT

Tech Stack

C#Open SourceFunctional Programming