>_ hackerrepos search repos…

← top repos

mcintyre321/OneOf

Easy to use F#-like ~discriminated~ unions for C# with exhaustive compile time matching

▲ 2 hackers recommend 2 strongly C# ★ 4.1k MIT c-sharpdiscriminated-unionsdotnetcoref-sharp

Recommended between 2025-10-05 and 2026-02-01. Last pushed 2026-09-27.

▲ 2 recommend · ▼ 0 criticisms

What hackers say

“some aspects being functional (`ErrorOr`[0] being a big part of it as well as `OneOf`[1])”

— CharlieDigital, 2026-02-01 · strong recommendation · original comment on Hacker News ↗

show original comment

You can write very functional C#. Our codebase is a mix with some aspects being functional (`ErrorOr`[0] being a big part of it as well as `OneOf`[1]) and OOP. Our core, common services all return `ErrorOr` to allow fluent call chaining at the top of the stack (controllers). Modern C# features like `switch` expressions[2] (not `switch-case`) and pattern matching mean that it is possible to write very terse, expressive code. Extension members and methods[3] go a long way as well by making the builder pattern easier to implement. Overall, it's up to the team to make use of the tools provided by the C# team. You can write C# in a very OOP heavy way (as is possible with TS in the case of Nest.…

“I have nothing to do with this library, I just like it”

— feoren, 2025-10-08 · strong recommendation · original comment on Hacker News ↗

show original comment

… basic wrapper like this. The user didn't say "Null", they said "Unknown" or "Not Applicable" or something. Record that. public OneOf<string, NotApplicable> Name A good OneOf implementation is here (I have nothing to do with this library, I just like it): https://github.com/mcintyre321/OneOf I wrote a JsonConverter for OneOf and just pass those over the wire.

Badge for your README

hackers recommend badge
[![hackers recommend](https://hackerrepos.org/badge/mcintyre321/oneof.svg)](https://hackerrepos.org/repo/mcintyre321/oneof)

Alternatives hackers mention