January 5, 2026

Railway code, comment trainwreck

Monads in C# (Part 2): Result

C# 'Result' promises cleaner errors—fans swoon, critics rage, theory cops roll in

TLDR: Alex Yorke champions a C# pattern that returns success or failure explicitly, chaining steps and short‑circuiting on errors. Commenters are split: fans love the clarity, skeptics hate the noisy syntax, and purists police the “monad” label—highlighting real tensions in how C# devs want to handle failure.

Alex Yorke drops Part 2 of his series, pitching Result as a cleaner way to handle failures: return Ok or Fail, chain steps, and let errors short‑circuit like “railway switching.” He even warns: don’t toss exceptions everywhere—use this when failure is expected. Sounds chill… until the comments turned into a coding cage match.

Superfan pimbrouwers flexed an open‑source library and gushed, “can’t imagine working without them.” Meanwhile, galkk fired the first grenade: that constant “Result<User, Error>” is “ugly and unergonomic,” pining for Google’s C++ macros like StatusOr and ASSIGN_OR_RETURN—translation: fewer keystrokes, more vibes. Then 89netraM brought academia to the party, touting a thesis and a cheeky C# prototype that uses the exclamation mark (!) as a “bind” operator, inspired by Haskell’s do‑notation—commenters immediately joked about ¡C# but make it spicy!

Practical folks like xnorswap slammed the classic “catch and rethrow as generic” pattern—why hide the real error? And the theory police showed up: epolanski argued you shouldn’t call everything a monad unless it obeys the math‑y laws. Cue memes: “railway switching” became “trainwreck switching” in the thread. Verdict? The post is clear and useful; the crowd is split between FP romantics, ergonomics warriors, and the monad law lawyers.

Key Points

  • Result<T, TError> represents success (Ok) or failure (Fail) and composes with Bind to propagate the first failure.
  • Result differs from Maybe by carrying an explicit error value (TError) in the failure case.
  • Use Bind for composition and defer branching/output to Match at boundaries.
  • Short-circuiting ensures that after a Fail, subsequent steps are skipped and the error flows through.
  • Result may be unsuitable for error accumulation or modeling multiple first-class outcomes; the post does not advocate replacing all exceptions.

Hottest takes

"I can’t imagine working without them anymore" — pimbrouwers
"looks extremely ugly and unergonomic, even just to type" — galkk
"part of me dies when data types that respect some laws are just labeled monads" — epolanski
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.