A.Pair (Aja v0.5.1) View Source

Convenience helpers for working with {atom, value} tuples without breaking the pipe.

Link to this section Summary

Functions

Unwraps an idiomatic {atom, value} tuple when the atom is what is being expected. Convenient for not breaking the pipe.

Wraps the value as an idiomatic {atom, value} tuple. Convenient for not breaking the pipe.

Link to this section Functions

Unwraps an idiomatic {atom, value} tuple when the atom is what is being expected. Convenient for not breaking the pipe.

Examples

iex> {:ok, 55} |> A.Pair.unwrap!(:ok)
55
iex> :error |> A.Pair.unwrap!(:ok)
** (ArgumentError) unwrap!/2 expected {:ok, _}, got: :error

Wraps the value as an idiomatic {atom, value} tuple. Convenient for not breaking the pipe.

Examples

iex> 55 |> A.Pair.wrap(:ok)
{:ok, 55}
iex> %{a: 5} |> Map.update!(:a, & &1 + 1) |> A.Pair.wrap(:no_reply)
{:no_reply, %{a: 6}}