A couple million lines of Haskell: Production engineering at Mercury

· ai · Source ↗

TLDR

  • Mercury runs 2 million lines of Haskell in production serving 300,000 businesses and $248B in 2025 transaction volume, with engineers mostly learning Haskell on the job.

Key Takeaways

  • Purity in Haskell is a boundary discipline, not a language property – runST is the canonical example of containing impurity behind a typed exit.
  • Encoding operational incantations (“flush audit log inside transaction”) in types prevents them from eroding as teams grow and senior engineers leave.
  • Mercury’s reliability philosophy centers on adaptive capacity – graceful degradation, operator legibility, blast-radius analysis – not just bug prevention.
  • Patrick McKenzie’s “half of your coworkers have under a year of experience” dynamic is a named design constraint at Mercury; type-encoded invariants survive team churn where wikis don’t.
  • Smaller ecosystem risk is real: Haskell library maintainers lack clear ownership, creating hesitation around breaking changes even when better designs are known.

Hacker News Comment Review

  • Commenters broadly agreed that encoding invariants in types is the core value, with debate over whether Rust and TypeScript deliver comparable power – OCaml’s GADTs and row polymorphism were cited as stronger than TypeScript’s nominal-type workarounds.
  • Productivity comparisons divided the thread: one engineer reported being 2x faster in Rust after 3 years of Haskell; another called switching a backend from TypeScript to Rust a major mistake due to higher-order function friction.
  • Several commenters attributed Mercury’s success as much to good engineering culture and being well-run generally as to Haskell specifically, and noted that hiring generalists with no prior Haskell helped Mercury impose its own style from day one.

Notable Comments

  • @1024bits: Hiring Haskell novices let Mercury instill culture and style from scratch – pre-vibe-coding, those hires wouldn’t have hacked away without instruction.

Original | Discuss on HN