Kotlin sealed classes and interfaces model finite domain states with compiler-checked exhaustive when expressions. Covers syntax, serialization, sealed interfaces for multiple inheritance, and production trade-offs: binary compatibility, DEX count, R8 stripping.
Discriminated unions in F# let you define a closed set of domain states and get compile‑time exhaustiveness checks when you pattern match, reducing boilerplate and preventing missed cases.
Give primitives semantic meaning with zero‑cost wrappers using Haskell’s DerivingVia. Learn the pattern, mechanics, a worked example, trade‑offs, and how to adopt it safely in your codebase.
A decision guide comparing Ceylon immutable classes, Java records, and manual POJOs for domain models, with a working Ceylon example and validation steps.
Stop using nulls and booleans to track state. Learn how F# Discriminated Unions make illegal program states unrepresentable through exhaustive pattern matching.
Stop relying on boolean flags to manage state. Learn how F# Discriminated Unions make illegal states unrepresentable and eliminate null-reference exceptions.
Learn how to use F# Discriminated Unions to eliminate invalid domain states and leverage exhaustive pattern matching for more robust, type-safe applications.