Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 4 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 (9 months ago)
- Default Branch: main
- Last Pushed: 2024-12-26T18:57:06.000Z (21 days ago)
- Last Synced: 2025-01-08T12:49:30.341Z (8 days ago)
- Topics: csharp, error-handling, functional-programming, monad
- Language: C#
- Homepage: https://badeend.github.io/Result/
- Size: 120 KB
- Stars: 2
- 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. It's about enhancing your existing C# code without overwhelming it with additional concepts.
- **For C# developers.** The goal is to make it feel "native" to the language, designed with C# conventions in mind, and avoiding a paradigm shift in how C# code is 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._