View Source Rail (rail v0.3.0)

Link to this section Summary

Functions

Apply a function or pipe to a function call when value is not {:error, _} or :error

Apply a function when value is not {:error, _} or :error

Link to this section Functions

Apply a function or pipe to a function call when value is not {:error, _} or :error

examples

Examples

iex> 1 >>> fn v -> Integer.to_string(v) end
"1"
iex> {:ok, 1} >>> fn v -> Integer.to_string(v) end
"1"
iex> {:ok, 1} >>> Integer.to_string()
"1"
iex> :error >>> Integer.to_string()
:error
iex> {:error, :div_by_zero} >>> Integer.to_string()
{:error, :div_by_zero}
@spec chain(any(), (any() -> any())) :: any()

Apply a function when value is not {:error, _} or :error

examples

Examples

iex> 1 |> Rail.chain(fn v -> v + 10 end)
11
iex> {:ok, 1} |> Rail.chain(fn v -> v + 10 end)
11
iex> :error |> Rail.chain(fn v -> v + 10 end)
:error
iex> {:error, :noent} |> Rail.chain(fn v -> v + 10 end)
{:error, :noent}
Link to this macro

def(head, body)

View Source (macro)
Link to this macro

defp(head, body)

View Source (macro)
Link to this macro

rail(head, body)

View Source (macro)
Link to this macro

railp(head, body)

View Source (macro)