Chaining Result-Generating Functions

Before we deal with our specific situation, we should step back and look at the big picture. In general, if we have some Result-generating functions, how can we compose them together in a clean way?

Here’s a visual representation of the problem. A normal function can be visualized as piece of railroad track:

images/single-track.png

But a function with a Result output can be visualized as a railroad track that splits into two, like this:

images/switch-track.png

I’m going to call these kinds of functions switch functions, after the railroad analogy. They’re ...

Get Domain Modeling Made Functional 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.