Chapter 4. Functional patterns for domain models

 

This chapter covers

  • Understanding functional design patterns and how they differ from OO design patterns
  • Algebra as patterns
  • Using monoids, the ubiquitous design pattern in functional programming
  • Working with patterns for programming with effects—functors, applicatives, and monads
  • Two use cases from the field that use types, algebra, and patterns to build domain models with better abstraction

The preceding chapter introduced the technique of algebraic API design and how you can think of composition of APIs before you have any implementation in your workspace. From now on when we talk about API design, we’ll focus on the algebra first. In this chapter, you’ll start finding patterns within the algebra of APIs. These design patterns are generic, parametric, and present themselves as artifacts that you can reuse across your domain models regardless of the nature of the domain that you’re modeling.

4.1. Patterns—the confluence of algebra, functions, and types

4.2. Basic patterns of computation in typed functional programming

4.3. How patterns shape your domain model

4.4. Evolution of an API with algebra, types, and patterns

4.5. Tighten up domain invariants with patterns and types

4.6. Summary

sitemap