nw-fp-domain-modeling
SolidDomain modeling with algebraic data types, smart constructors, and type-level error handling
AI & Automation 526 stars
55 forks Updated 1 weeks ago MIT
Install
Quality Score: 95/100
Stars 20%
Recency 20%
Frontmatter 20%
Documentation 15%
Issue Health 10%
License 10%
Description 5%
Skill Content
# FP Domain Modeling
Domain modeling with types. Make illegal states unrepresentable, workflows as pipelines, error handling at the type level.
Cross-references: [fp-principles](../nw-fp-principles/SKILL.md) | [fp-hexagonal-architecture](../nw-fp-hexagonal-architecture/SKILL.md) | [fp-algebra-driven-design](../nw-fp-algebra-driven-design/SKILL.md)
---
## 1. The Two Building Blocks
[STARTER]
All domain types compose from two operations:
- **AND (Record Types)**: Value has ALL of these fields. Order requires CustomerInfo AND ShippingAddress AND OrderLines.
- **OR (Choice Types)**: Value is ONE OF these alternatives. ProductCode is either WidgetCode OR GizmoCode.
Combined recursively, these express virtually any domain structure.
---
## 2. Domain Wrappers for Primitives
[STARTER]
Never use primitives directly in the domain model. Each domain concept gets its own wrapper type.
**What**: Wrap primitives so the compiler distinguishes CustomerId from OrderId.
**When**: Every primitive with domain meaning.
**Why**: Prevents accidental mixing (compiler rejects comparing CustomerId with OrderId). Each wrapper carries its own validation rules. The type name IS the documentation.
---
## 3. Validated Construction (Smart Constructors)
[STARTER]
Raw constructor is private. A `create` function validates input and returns a Result type, making validation failure explicit.
**Pattern**: UnitQuantity must be between 1 and 1000. Its `create` function rejects values outside that ...
Details
- Author
- nWave-ai
- Repository
- nWave-ai/nWave
- Created
- 3 months ago
- Last Updated
- 1 weeks ago
- Language
- Python
- License
- MIT
Similar Skills
Semantically similar based on skill content — not just same category
DevOps & Infrastructure Solid
nw-fp-principles
Core functional programming thinking patterns and type system foundations, language-agnostic
526 Updated 1 weeks ago
nWave-ai AI & Automation Solid
nw-fp-fsharp
F# language-specific patterns, Railway-Oriented Programming, and Computation Expressions
526 Updated 1 weeks ago
nWave-ai AI & Automation Solid
nw-fp-haskell
Haskell language-specific patterns, GADTs, type classes, and effect systems
526 Updated 1 weeks ago
nWave-ai AI & Automation Listed
domain-modeling
Use for domain modeling, data shapes, invariants, state transitions, parsing, and effects.
0 Updated yesterday
kreek Web & Frontend Solid
nw-fp-algebra-driven-design
Algebra-driven API design with monoids, semigroups, and interpreters via algebraic equations
526 Updated 1 weeks ago
nWave-ai