Hacker GitHub

← All repos

mcintyre321/OneOf

View on GitHub ↗ ★ 4,060 C#

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

29 mentions on Hacker News by 10 people: 3 stories, 26 comments · first 2016-08-25 · latest 2026-02-01

Mentions per year 29 mentions · busiest year 2024 (6)
20082026
  1. …from F# over the years. It's up to the team. [0] https://github.com/amantinband/error-or [1] https://github.com/mcintyre321/OneOf [2] https://timdeschryver.dev/blog/pattern-matching-examples-in-... [3]…
  2. …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.
  3. …to get access to DU [0] https://timdeschryver.dev/blog/pattern-matching-examples-in-... [1] https://github.com/mcintyre321/OneOf [2] https://github.com/domn1995/dunet
    comment by CharlieDigital · 2025-10-05 · in What .NET 10 GC changes mean for developers
  4. …Why would I want to use this instead of a more general approach to discriminated unions, eg. like: https://github.com/mcintyre321/OneOf If I would use your library I would need a separate solution for every other case. Take care, Martin
  5. …we wait for the official discriminated union feature, the OneOf package is a pretty good stand-in: https://github.com/mcintyre321/OneOf
    comment by feoren · 2025-04-01 · in Why F#?
  6. There's also OneOf ( https://github.com/mcintyre321/OneOf ) as well which feels more ergonomic to me (having used both). Practical example in a short write up here: https://chrlschn.dev/blog/2024/07/csharp-discriminated-union...
  7. …example of using this: https://chrlschn.dev/blog/2024/07/csharp-discriminated-union... [0] https://github.com/mcintyre321/OneOf [1] https://github.com/domn1995/dunet
    comment by CharlieDigital · 2024-10-18 · in Net 9.0 LINQ Performance Improvements
  8. …allows your models to evolve over time without changing your function signatures at the edge. [0] https://github.com/mcintyre321/OneOf
    comment by conor- · 2024-08-08 · in Official proposal for Type Unions in C#
  9. …to add DUs in C# today with some third party packages. - https://github.com/domn1995/dunet - https://github.com/mcintyre321/OneOf Quite good and ergonomic with the source generators removing a lot of the boilerplate. I have a practical…
    comment by CharlieDigital · 2024-08-07 · in Official proposal for Type Unions in C#
  10. …hn.dev/blog/2023/08/dotnet-source-generators-d... [2] https://www.youtube.com/watch?v=GlnEm7JyvyY [3] https://github.com/mcintyre321/OneOf
    comment by CharlieDigital · 2024-05-16 · in Swift sucks at web serving or does it?
  11. ▲ 2
    Easy to use F#-like ~discriminated~ unions for C# with big compile time matching
    story by keepamovin · 2024-01-20 · 0 comments
  12. Until that feature lands there's this https://github.com/mcintyre321/OneOf which is pretty nice.
    comment by conor- · 2023-10-20 · in What's new in C# 12: overview
  13. DU is available in C# via packages like OneOf and Dunet. Dunet is really good. https://github.com/mcintyre321/OneOf https://github.com/domn1995/dunet It's on the roadmap and will arrive at some point: https://github.com/dotnet/csharplang/bl…
    comment by CharlieDigital · 2023-08-24 · in Bun v0.8
  14. Agree. For now, you can get a reasonable DU via an [external library]( https://github.com/mcintyre321/OneOf ). [Nick Chapsas Video on Usage]( https://www.youtube.com/watch?v=7z-xjijYfcI ).
    comment by ftcHn · 2023-08-07 · in The combined power of F# and C#
  15. …it's usually a class type. 1) https://learn.microsoft.com/en-us/dotnet/api/system.nullable... 2) https://github.com/mcintyre321/OneOf/blob/master/OneOf/OneOf...
  16. ▲ 1
    OneOf – F# style discriminated unions for C#
    story by vyrotek · 2023-01-17 · 0 comments
  17. Apologies, but here's the obligatory link to my OneOf exhaustive type matching library: https://github.com/mcintyre321/OneOf
    comment by macca321 · 2020-02-04 · in C# Pattern Matching
  18. I maintain a library for doing exactly this in C# ( https://github.com/mcintyre321/OneOf ). I tried to replicate it in Python as I'm writing it at the moment, but couldn't quite manage it. Can you have a multi generic typed Union in python?
  19. You can get a pretty reasonable facsimile using some libraries I made: Discriminated unions: https://github.com/mcintyre321/OneOf and One line value objects: https://github.com/mcintyre321/ValueOf
  20. ... and exhaustive matching: https://github.com/mcintyre321/OneOf I'm not saying it's as good as writing F#, or that C# shouldn't include these features of course.
  21. If you're after Option or ADTs (Unions) for C#, I can heartily recommend https://github.com/mcintyre321/OneOf , it's brilliant. But then I would say that ;)
    comment by macca321 · 2018-11-09 · in What Makes .NET Core So Special?
  22. …what types get passed in, nor can you ensure that all possible types actually get handled. [1]: https://github.com/mcintyre321/OneOf/
    comment by coldacid · 2018-03-12 · in Tuples goodness in .NET 4.7.1
  23. We're singing from the same hymn sheet :) https://github.com/mcintyre321/OneOf https://github.com/mcintyre321/ValueOf
    comment by macca321 · 2017-08-17 · in The Problem with F# Evangelism
  24. We're singing from the same hymn sheet https://github.com/mcintyre321/OneOf https://github.com/mcintyre321/ValueOf
    comment by macca321 · 2017-08-16 · in The Problem with F# Evangelism
  25. …I don't know if this would work in Java, given the generic type erasure, but it might... 1. https://github.com/mcintyre321/OneOf
    comment by macca321 · 2017-04-20 · in Pattern Matching for Java
  26. …at the lack of exhaustive matching / Discriminated Unions, please try out my library OneOf* ( https://github.com/mcintyre321/OneOf ). Hopefully something similar will be brought into C# soon, but in the meantime, these libraries provide…
    comment by macca321 · 2017-03-10 · in New Features in C# 7.0
  27. ▲ 2
    OneOf: Easy to use F#-like discriminated unions for C#
    story by macca321 · 2016-09-27 · 0 comments
  28. I'm just going to pimp my library (github.com/mcintyre321/OneOf) which lets you pull this off in c#. I'm quite sad it's needed though, it would be great to have it in the language.
    comment by macca321 · 2016-08-25 · in What’s New in C# 7.0
  29. You can achieve something similar via a library: https://github.com/mcintyre321/OneOf I also think language level support for this would be a killer feature, it turns OOP and the requirement to use polymorphism to guarantee…
    comment by macca321 · 2016-08-25 · in What’s New in C# 7.0