OkThen.Result.Pipe (ok_then v0.1.1)
Convenience operators for handling of tagged results in pipelines.
Link to this section Summary
Functions
Equivalent to OkThen.Result.map(result, func_or_default)
. See OkThen.Result.map/2
.
Equivalent to OkThen.Result.then(result, func_or_default)
. See OkThen.Result.then/2
.
Link to this section Functions
Equivalent to OkThen.Result.map(result, func_or_default)
. See OkThen.Result.map/2
.
Examples
iex> add_one = &(&1 + 1)
iex> {:ok, 1}
...> ~> add_one.()
...> ~> add_one.()
{:ok, 3}
iex> add_one = &(&1 + 1)
iex> {:error, 1}
...> ~> add_one.()
...> ~> add_one.()
{:error, 1}
iex> {:ok, 1}
...> ~> "hello"
{:ok, "hello"}
iex> {:error, 1}
...> ~> "hello"
{:error, 1}
iex> "bare value"
...> ~> "hello"
"bare value"
iex> add_one = &(&1 + 1)
iex> "bare value"
...> ~> add_one.()
"bare value"
Equivalent to OkThen.Result.then(result, func_or_default)
. See OkThen.Result.then/2
.
Examples
iex> add_one = &({:ok, &1 + 1})
iex> {:ok, 1}
...> ~>> add_one.()
...> ~>> add_one.()
{:ok, 3}
iex> add_one = &({:ok, &1 + 1})
iex> {:error, 1}
...> ~>> add_one.()
...> ~>> add_one.()
{:error, 1}
iex> {:ok, 1}
...> ~>> {:ok, "hello"}
{:ok, "hello"}
iex> {:error, 1}
...> ~>> {:ok, "hello"}
{:error, 1}
iex> "bare value"
...> ~>> {:ok, "hello"}
"bare value"
iex> add_one = &(&1 + 1)
iex> "bare value"
...> ~>> add_one.()
"bare value"