This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Utils.GuardPipe do | |
@moduledoc ~S""" | |
When a value input into the pipe is an error tuple, the subsequent function in the pipeline will not execute, and the error tuple is immediately returned as the output. | |
Example: | |
iex> {:error, 9} ~> Kernel.+(1) | |
{:error, 9} | |
On the other hand, if the input is an `ok` tuple, its inner value is extracted and passed on to the next function in the pipeline. The final output of the pipe will be either an `ok` or an `error` tuple. |