Quickstart
Ready to eliminate null checks and stop catching exceptions? Here's how to get up and running with Waystone.Monads.
Installation
Install via the dotnet CLI:
dotnet add package Waystone.MonadsUsing Option<T>
The Option<T> type represents a value that may or may not be present. It eliminates the ambiguity and risks of null , and provides a way to mark a value as intentionally absent.
Option<string> name = Option.Some("Liam O'Brian");
Option<string> missing = Option.None<string>();
string greeting = name.Match(
some => $"Hello, {some}!",
() => "Hello, stranger!"
);
// Output: "Hello, Liam O'Brian!"Using Result<T, E>
The Result<T, E> type represents a success or failure as a value instead of throwing exceptions. It allows you to reserve exceptions for exceptional scenarios, and provides a framework for handling success and failure outcomes explicitly. Use it instead of throwing exceptions for recoverable failures.
No exceptions, no try/catch, just predictable control flow
Last updated
Was this helpful?