Danom is a C# library that provides (monadic) structures to facilitate durable programming patterns in C# using Option and Result. Options have an und

Search code, repositories, users, issues, pull requests...

submited by
Style Pass
2024-11-29 14:30:03

Danom is a C# library that provides (monadic) structures to facilitate durable programming patterns in C# using Option and Result.

Options have an underlying type and can "optionallu" hold a value of that type. Options are a much safer way to handle nullable values, they virtually eliminate null reference exceptions, and a fantastic means of reducing primitive congestion in your code.

Options are commonly used when a operation might not return a value. For example, the method below tries to find a number in a list that satisfies a predicate. If the number is found, it is returned as a Some, otherwise, None is returned.

Results are used to represent a success or failure outcome. They provide a more concrete way to manage the expected errors of an operation, then throwing exceptions. Especially in recoverable or reportable scenarios.

Results are commonly used when an operation might not succeed, and you want to manage or report back the expected errors. For example:

Leave a Comment