Maybex v1.0.0 Maybe.Pipe View Source
Macro for piping conditionally into the next function.
If the value piped in is an error tuple the next function in the pipe will not be called and the value is returned.
iex> {:error, 5} ~> Kernel.+(2)
If the value piped in is an ok tuple it will be flattened to just the value contained within the tuple when passed to functions in the pipe.
The value finally returned from the pipe will be an ok/error tuple.
iex> {:ok, 5} ~> Kernel.+(2)
iex> {:ok, 5} ~> Kernel.+(2) ~> Kernel.+(3)
If the value piped in is not an ok/error tuple a IncorrectMaybePipeError will be raised.
In cases where a non-tuple value needs to be passed in a regular pipe (|>) should be used instead.
For more information about the motivation for this macro you can start reading about point-free programming. It solves one of the two hardest problems in programming: naming things.