Functional Patterns in Domain Modeling
summary
Argues for building domain APIs from verbs-first algebras of types, functions and laws using Scala’s static type system; composes behaviors by reusing categorical algebras (monoid, functor, monad) and the Kleisli and Monad Transformers patterns so a trade pipeline is expressed as composable Kleisli values long before any concrete implementation. Shows ListT/OptionT to stack repetition and error effects, Free monads to separate interpreters, and property‑based tests to verify domain laws; claims fewer lines of code, multiple interpreters and stronger compile‑time guarantees.
AI-written summary · about
chapters (22)
- 0:00Introduction
- 1:08What is domain modeling
- 2:30Functional approach to modeling
- 3:55Problem vs solution domain
- 4:39Rich vs lean domain models
- 7:35Verbs first design
- 8:19API evolution via algebra
- 11:38Securities trading example
- 13:25Monoid explained
- 15:56Formalizing domain algebra
- 17:22Modeling and API evolution
- 18:10Use case order processing
- 21:45Initial algebra for trading
- 24:16Refactoring for composability
- 26:54Functions with monads/kleisli
- 31:54Trade generation implementation
- 34:29Error handling with monad transformers
- 37:20Algebra with error reporting
- 42:42Domain rules and testing
- 44:27Free monads decoupling
- 47:41Key takeaways
- 49:12Q&A
related talks
34mPatterns of a pragmatic functional architecture
49mMining Functional Patterns
46mAlgebraic Thinking for evolution of pure functional domain models
33mFunctional Patterns and Gems in Scala
37mIntro to FP in Scala: Exploring a Toolbox for Solving Problems - Part 6 of 6
01h 02mPrinciples and tools to cleverly model your data in Scala
55mMonoids, Monoids, Monoids
35mIntroducing Typelevel Scala into an OO environment
