TL;DR
The article argues that functional programming and algebraic data types (ADTs) push many classes of bugs out of reach by encoding valid states in the type system. Examples from banking, telecom and config parsing show how ADTs, pattern matching, Option/Result types and immutability make systems safer and refactors more reliable.
What happened
The piece lays out a practical case that reliability in critical systems is improved when domain rules are encoded in types rather than enforced by convention or runtime checks. It highlights recurring incident patterns — unexpected string values, nulls, conflicting booleans and incomplete lifecycle transitions — and shows how product and sum types can make illegal states unrepresentable. Pattern matching with exhaustiveness checking forces developers to handle every case and makes adding a new variant a compile-time prompt to update all relevant logic. The author walks through concrete domain remodelings for transaction lifecycles, call sessions and configuration parsing, showing how Option/Result types replace nulls and exceptions and how immutable data and pure functions reduce surprising behaviors. The article also promises a migration playbook aimed at junior and mid-level engineers for adopting these techniques in production.
Why it matters
- Encoding business rules in types prevents whole classes of runtime errors before the code runs.
- Exhaustive pattern matching turns refactors into safer, compiler-assisted edits.
- Explicit Option/Result types make absence and failure cases visible and deliberate.
- Immutability and pure functions simplify reasoning about state in high-availability systems.
Key facts
- Common production incidents often arise from states that should not have been possible, not from algorithmic complexity.
- Product types (records/tuples) compose fields; sum types (tagged unions) express choice among variants.
- With discriminated unions, the compiler rejects invalid variants — e.g., an unsupported payment method cannot be constructed.
- Pattern matching plus exhaustiveness checks forces updates across the codebase when a new variant is added.
- A transaction lifecycle modeled as an ADT prevents illegal transitions (for example, settling a reversed transaction) and allows transition functions to return Result types on invalid operations.
- Call session states modeled as ADTs can separate billable from non-billable states, preventing ghost billing caused by missing end events.
- Parsing configuration with Result types removes silent failures (for example, Number('30s') producing NaN) and makes parse errors explicit.
- Option (Maybe) and Result (Either) types are recommended over nulls and exceptions for handling optional values and expected failures.
- Immutable data structures and pure functions reduce the cognitive load of reasoning about state changes across concurrent systems.
What to watch next
- A migration playbook for applying these techniques at junior and mid-levels is referenced in the article and intended for practical team adoption.
- not confirmed in the source
- not confirmed in the source
Quick glossary
- Algebraic Data Type (ADT): A composite type built from product types (combinations of fields) and sum types (a choice among alternatives) used to model domain invariants.
- Product type: A type that combines multiple fields together (think 'and'), like a record or struct.
- Sum type (Tagged union): A type that can be one of several distinct variants (think 'or'), typically discriminated by a tag so each case carries its own data.
- Option / Maybe: A type representing presence or absence of a value, used instead of null to make optionality explicit.
- Result / Either: A type representing a successful value or an error, used to surface expected failures without exceptions.
Reader FAQ
Will functional programming eliminate all production bugs?
No. The article says encoding invariants in the type system removes entire classes of bugs, but it also notes that testing and coverage still matter.
Can these ADT patterns be used in JavaScript/TypeScript?
Yes; the source presents TypeScript discriminated unions and Option/Result encodings as practical examples.
Does the article provide a migration plan for teams?
It references a migration playbook aimed at junior and mid-level engineers to apply the techniques in practice.
Will adopting ADTs harm runtime performance?
not confirmed in the source

Why Reliability Demands Functional Programming: ADTs, Safety, and Critical Infrastructure By Rastrian on 2025-09-16 at 16:29 UTC View on GitHub In banking, telecom, and payments, reliability is not a nice…
Sources
- Why Reliability Demands Functional Programming
- Unlocking the Power of Functional Programming Patterns
- Algebraic Data Types: Things I wish someone had explained …
- Functional programming: benefits for software development
Related posts
- Pfizer passed on early GLP‑1 research in the early 1990s, says Flier
- An ounce of silver now fetches a higher price than a barrel of oil
- Yanis Varoufakis on the Future of Capitalism, Cloud Capital and Tech Power