tagged v0.1.0 Tagged View Source

Generates definitions of various things related to tagged value tuples, like {:ok, value} and {:error, reason}.

Examples

defmodule Tagged.Status
  use Tagged

  deftagged ok
  deftagged error
end

Construct and Destructure

iex> use Tagged.Status
iex> ok(:computer)
{:ok, :computer}
iex> with error(reason) <- {:ok, :computer}, do: raise reason
{:ok, :computer}

Type definitions

_iex> use Tagged.Status
_iex> t Tagged.Status.error
@type error() :: {:error, term()}

Tagged value tuple, containing term().

Link to this section Summary

Functions

Generates a macro that definies all things related to a tagged value tuple, {atom(), term()}. By default the macro has the same name as the tag, and all the things are generated.

Link to this section Functions

Link to this macro

deftagged(tag, opts \\ [])

View Source (macro) (since 0.1.0)

Generates a macro that definies all things related to a tagged value tuple, {atom(), term()}. By default the macro has the same name as the tag, and all the things are generated.

Keywords