7 Requirements as types

In this chapter you will learn

  • how to model your immutable data to minimize errors
  • how to model your requirements as immutable data
  • how to find problems in requirements using the compiler
  • how to make sure your logic is always executed on valid data

Designing something just powerful enough is an art.

—Barbara Liskov

Modeling data to minimize programmers’ mistakes

In this chapter we will change the way we model data in our applications. We will use more types to minimize potential programmer mistakes. We will learn techniques that enhance the maintainability of our codebases. We will also make implementations smaller and less complicated! Too good to be true? Let’s see this in action using an example.

We focus a lot ...

Get Grokking Functional Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.