← ClaudeAtlas

typescript-functional-patternslisted

Functional programming patterns for reliable TypeScript. Use when modeling state machines, discriminated unions, Result/Option types, branded types, or building type-safe domain models.
martinffx/atelier · ★ 28 · AI & Automation · score 83
Install: claude install-skill martinffx/atelier
# Functional Patterns for Reliable TypeScript Build reliable systems using Algebraic Data Types (ADTs), discriminated unions, Result/Option types, and branded types. These patterns enable the compiler to prove correctness, prevent runtime errors, and make illegal states unrepresentable. ## Why Functional Patterns? **Reliability through types**: Use the type system to encode business rules, making invalid states impossible to construct. The compiler becomes your safety net, catching errors at build time rather than runtime. **Key benefits:** - Exhaustiveness checking prevents missing cases - Impossible states become unrepresentable - Business logic encoded in types, not runtime checks - Refactoring becomes safe and mechanical - Self-documenting code through types ## Quick Reference For detailed patterns and examples, see: - [ADTs (Algebraic Data Types)](./references/adts.md) - Sum types, product types, discriminated unions - [Option & Result](./references/option-result.md) - Type-safe error handling and nullable values - [Branded Types](./references/branded-types.md) - Smart constructors and nominal typing - [Migration Guide](./references/migration-guide.md) - Step-by-step adoption playbook ## Core Patterns Overview ### 1. Discriminated Unions (Sum Types) Model "one of several variants" with exhaustive pattern matching: ```typescript type PaymentMethod = | { kind: "card"; last4: string; brand: string } | { kind: "ach"; accountNumber: string; routingNumber: string