Welcome
Keep exceptions exceptional
Waystone.Monads gives C# two types that say what your code actually means.
Option<T>— the value might not be there.Result<T, E>— the work might fail.
Both are ordinary C# types. There is no framework to adopt and nothing to wire up. You add a package, you change a return type, and the compiler starts telling you about the cases you used to find at runtime.
Who this is for
You are writing C# and you are tired of two things: null reaching places it should not, and exceptions being used for outcomes that are not exceptional.
The library replaces both with values you can return, pass around, and compose. Absence and failure stop being surprises hidden inside a method body, and start being part of the signature you already read.
If you have used Option and Result in Rust or F#, you already know the shape. If you have not, Why monads walks through it with no prior knowledge assumed.
Where to go next
Install the package and see both types work
Understand why this beats null and try/catch
Teach your coding agent to write it properly
What comes in the box
Installing Waystone.Monads gets you the two types, a Roslyn analyzer, and a source generator. You configure none of it. The analyzer flags the mistakes people make with these types, and the generator turns an enum into a set of error codes. See Analyzer rules and Generated error codes.
Optional packages sit beside the library — Shouldly assertions, LINQ query syntax, JSON converters, and more. None is required, and none changes how Waystone.Monads behaves. Add-ons extend the library itself. Integrations connect it to a library you already use.
Links
Source on GitHub — the
Waystone.Monadspackage lives insrc/Waystone.MonadsReport an issue — for the library or for these docs
Last updated
Was this helpful?
