O'Reilly logo

Domain Modeling Made Functional by Scott Wlaschin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modeling Each Step in the Workflow with Types

The state machine approach is perfect for modeling our order-placing workflow, so with that in hand, let’s now model the details of each step.

The Validation Step

Let’s start with validation. In the earlier discussion, we documented the “ValidateOrder” substep like this:

 substep "ValidateOrder" =
  input: UnvalidatedOrder
  output: ValidatedOrder OR ValidationError
  dependencies: CheckProductCodeExists, CheckAddressExists

We’ll assume that we’ve defined the input and output types (UnvalidatedOrder and ValidatedOrder) in the same way as in the discussion earlier. In addition to the input, we can see that the substep has two dependencies, one to check that a product code exists and one to check that ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required