typescript-functional-patterns

Solid

Functional programming patterns for reliable TypeScript. Use when modeling state machines, discriminated unions, Result/Option types, branded types, or building type-safe domain models.

AI & Automation 38 stars 3 forks Updated today MIT

Install

View on GitHub

Quality Score: 87/100

Stars 20%
53
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# 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...

Details

Author
martinffx
Repository
martinffx/atelier
Created
6 months ago
Last Updated
today
Language
TypeScript
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category