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:
But a function with a Result output can be visualized as a railroad track that splits into two, like this:
I’m going to call these kinds of functions switch functions, after the railroad analogy. They’re ...