https://github.com/badeend/result
For failures that are not exceptional: `Result<T,E>` for C#.
https://github.com/badeend/result
csharp error-handling functional-programming monad
Last synced: 11 days ago
JSON representation
For failures that are not exceptional: `Result<T,E>` for C#.
- Host: GitHub
- URL: https://github.com/badeend/result
- Owner: badeend
- License: mit
- Created: 2024-04-07T08:35:26.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-09T11:00:30.000Z (4 months ago)
- Last Synced: 2025-06-26T19:58:29.985Z (18 days ago)
- Topics: csharp, error-handling, functional-programming, monad
- Language: C#
- Homepage: https://badeend.github.io/Result/
- Size: 152 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
![]()
For failures that are not exceptional.---
This packages provides a `Result` type for C#, spiritually similar to those available in [Rust](https://doc.rust-lang.org/std/result/enum.Result.html), [Swift](https://developer.apple.com/documentation/swift/result), [Kotlin](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/), [C++](https://en.cppreference.com/w/cpp/utility/expected) and basically every functional programming language under the sun.
Results are commonly used in scenarios where failure is anticipated can be handled gracefully by the caller. Examples include:
- Input validation,
- Parsing and conversion,
- Invocation of external services,
- Authentication and authorization,
- and more ...`Result` represents the result of a fallible operation as a first class value. A result can be in one of two states: "success" or "error". Both states have an associated payload of type `TValue` or `TError` respectively.
---
**Documentation & more information at: https://badeend.github.io/Result/**
---
#### Why does this package exist?
While there are many similar packages available, this one is designed to address specific needs that others did not fully meet:
- **No opinion on what is allowed to be an error.** The error type (`TError`) is parameterized without constraints.
- **Focus on simplicity.** This package is designed to provide just what's needed without introducing an extensive Functional Programming framework. Users should be able to sprinkle on Results in existing codebases without overwhelming it with additional FP concepts.
- **For C# developers.** The goal is to make it feel as "native" to the language as possible, using .NET naming & design conventions, and avoiding a paradigm shift in how C# code ought to be written.---
### Shameless self-promotion
May I interest you in one of my other packages?
- **[Badeend.ValueCollections](https://badeend.github.io/ValueCollections/)**: _Low overhead immutable collection types with structural equality._
- **[Badeend.EnumClass](https://badeend.github.io/EnumClass/)**: _Discriminated unions for C# with exhaustiveness checking._
- **[Badeend.Result](https://badeend.github.io/Result/)**: _For failures that are not exceptional: `Result` for C#._
- **[Badeend.Any](https://badeend.github.io/Any/)**: _Holds any value of any type, without boxing small structs (up to 8 bytes)._
- **[Badeend.Nothing](https://github.com/badeend/Nothing)**: _If you want to use `void` as a type parameter, but C# won't let you._