https://github.com/comradevanti/res-csharp
A C# library that mimics F#'s results
https://github.com/comradevanti/res-csharp
Last synced: 8 months ago
JSON representation
A C# library that mimics F#'s results
- Host: GitHub
- URL: https://github.com/comradevanti/res-csharp
- Owner: ComradeVanti
- License: unlicense
- Created: 2022-03-14T11:05:36.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-03-19T10:33:33.000Z (over 1 year ago)
- Last Synced: 2025-02-21T08:34:20.050Z (8 months ago)
- Language: C#
- Size: 45.9 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Res
[](https://www.nuget.org/packages/ComradeVanti.CSharpTools.Res)
A C# library that mimics F#'s results. Since the functionality and in most cases
even the method names are directly taken from F#, go check
out [the documentation there](https://fsharp.github.io/fsharp-core-docs/reference/fsharp-core-resultmodule.html)
for details.[Changelog](https://github.com/ComradeVanti/res-csharp/blob/main/CHANGELOG.md)
**⚠️ Development is paused ⚠️**
No new features will be added or bugs fixed unless requested through an issue.
If you wish to fork this repository and continue the work, you are very welcome
to do so.## Features
Methods for creating results are located on the `Res` class. Values can also be
implicitly cast to `Res` instances. Methods like `Map`
or `Bind` are available as extension methods on `Res` instances for easy
chaining.`Res` are immutable reference-types. They are compared using equality even when
using `==`.### Result instantiation
- Ok
- Fail
- FromOpSuccess and Fail results may also be implicitly cast from their containing
values like this
`Res res = 0`### Result extension methods
- IsOk
- IsFail
- Match (for functions and actions)
- Bind
- Map
- MapError### Async mapping
There are also async versions of
- Map
- Bind
- MapErrorThey are found by simply adding "Async" to the end of the method-name
There are also extension methods for `Task>` such as
- MapAsyncRes
- MapAsyncResError
- BindAsyncRes
- BindAsyncResAsync