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

Implementing the Rest of the Steps

Now that we’ve seen how to implement validateOrder, we can use the same techniques to build the rest of the pipeline functions.

Here’s the original design of the pricing step function, with effects:

 type​ PriceOrder =
  GetProductPrice ​// dependency
  -> ValidatedOrder ​// input
  -> Result<PricedOrder, PlaceOrderError> ​// output

But again, we’ll eliminate the effects for now, leaving this design:

 type​ GetProductPrice = ProductCode -> Price
 type​ PriceOrder =
  GetProductPrice ​// dependency
  -> ValidatedOrder ​// input
  -> PricedOrder ​// output

And here’s the outline of the implementation. It simply transforms each order line to a PricedOrderLine and builds a new PricedOrder with them:

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