OkThen.Result.normalize
You're seeing just the function
normalize
, go back to OkThen.Result module for more information.
Link to this function
normalize(result, default_tag \\ :untagged)
Specs
normalize(result_input(), atom()) :: tagged()
Converts result
from a variety of accepted result-like terms into an atom or a two-element
tagged tuple.
If result
is not a tagged tuple, it is wrapped as a new result
Examples
iex> Result.normalize(:ok)
:ok
iex> Result.normalize({:ok, "hello"})
{:ok, "hello"}
iex> Result.normalize({:ok, 1, 2})
{:ok, {1, 2}}
iex> Result.normalize(:error)
:error
iex> Result.normalize({:error, "hello"})
{:error, "hello"}
iex> Result.normalize({:error, 1, 2})
{:error, {1, 2}}
iex> Result.normalize(:none)
:none
iex> Result.normalize({:strange, ["hello", 1, 2]})
{:strange, ["hello", 1, 2]}
iex> Result.normalize("hello")
{:untagged, "hello"}
iex> Result.normalize({1, 2})
{:untagged, {1, 2}}
iex> Result.normalize({})
:untagged
iex> Result.normalize({1, 2}, :error)
{:error, {1, 2}}
iex> Result.normalize(nil)
:none
iex> Result.normalize(nil, :error)
:none