tagged v0.1.0 Tagged.Outcome View Source

Reasoning in terms of the outcome of an action.

iex> use Tagged.Outcome
iex> failure(:is_human)
{:error, :is_human}
iex> with success(it) <- {:ok, "Computer"}, do: "OK, #{it}!"
"OK, Computer!"

Link to this section Summary

Types

Tagged value tuple, containing term().

Tagged value tuple, containing term().

Functions

Constructor for error tagged value tuples. Can also be used to destructure tuples.

Constructor for ok tagged value tuples. Can also be used to destructure tuples.

Link to this section Types

Specs

failure() :: {:error, term()}

Tagged value tuple, containing term().

Specs

success() :: {:ok, term()}

Tagged value tuple, containing term().

Link to this section Functions

Link to this macro

failure(value)

View Source (macro)

Specs

failure(term()) :: failure()

Constructor for error tagged value tuples. Can also be used to destructure tuples.

iex> use Elixir.Tagged.Constructor
iex> with failure(val) <- {:error, :match}, do: val
:match
iex> with failure(_) <- {:not_error, :match}, do: true
{:not_error, :match}
Link to this macro

success(value)

View Source (macro)

Specs

success(term()) :: success()

Constructor for ok tagged value tuples. Can also be used to destructure tuples.

iex> use Elixir.Tagged.Constructor
iex> with success(val) <- {:ok, :match}, do: val
:match
iex> with success(_) <- {:not_ok, :match}, do: true
{:not_ok, :match}