Railway Oriented Programming
Elixir has a nice take on this with the `with` keyword&#x2F;macro<p><pre><code>    with {:ok, file_handle} &lt;- File.open(filename),

         {:ok, contents} &lt;- IO.read(file_handle),

         {:ok, parsed} &lt;- MyModule.parse(contents)

    do

       {:ok, parsed}

    end
</code></pre>
what this does is run the functions in order top to bottom, and if the return value from each function doesn&#x27;t match with what is on the left, it returns early with the thing that didn&#x27;t match, otherwise it continues.<p>This means you don&#x27;t need to write each function to take a tuple of {:ok, value} and another clause to take {:error, reason}, you can just write your functions to take the value they care about and let pattern matching in the with block to take care of error propagation.<p>so if File.open returns {:error, reason} then IO.read never executes and the result of the with is {:error, reason}<p>It essentially means you can program the happy path and let the caller match on the sad paths (if they want to)