tagged v0.3.0 Tagged View Source
Generates definitions of various things related to tuples with a tagged value,
such as the ubiquitous {:ok, value} and {:error, reason}.
Examples
defmodule Tagged.Status
use Tagged
deftagged ok
deftagged error
endConstruct and Destructure
iex> require Tagged.Status, as: Status
iex> Status.ok(:computer)
{:ok, :computer}
iex> with Status.error(reason) <- {:ok, :computer}, do: raise reason
{:ok, :computer}See Tagged.Constructor for further details.
Type definitions
_iex> t Tagged.Status.error
@type error() :: {:error, term()}
Tagged value tuple, containing term().See Tagged.Typedef for further details.
Pipe selective execution
iex> require Tagged.Status
iex> import Tagged.Status, only: [ok: 1, with_ok: 2]
iex> ok(:computer) |> with_ok(& "OK, #{&1}")
"OK, computer"See Tagged.PipeWith for further details.
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
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
as: nameOverride default macro name. See
Tagged.Constructor.of: typedefDeclare the wrapped type statically, making it opaque. See
Tagged.Typedef.type: falseOverride generation of type definition. See
Tagged.Typedef.pipe_with: falseOverride generation of pipe filter. See
Tagged.PipeWith.