
[](https://coveralls.io/github/notCalle/elixir-tagged?branch=master)
[](https://hex.pm/packages/tagged)
[](https://hexdocs.pm/tagged)
[](https://github.com/notCalle/elixir-tagged/blob/master/LICENSE.txt)
# Tagged
Generates definitions of various things related to tuples with a tagged value,
such as the ubiquitous `{:ok, value}` and `{:error, reason}`.
## Examples
```elixir
defmodule Tagged.Status
use Tagged
deftagged ok
deftagged error
end
```
### Construct and Destructure
```elixir
iex> use Tagged.Status
iex> ok(:computer)
{:ok, :computer}
iex> with error(reason) <- {:ok, :computer}, do: raise reason
{:ok, :computer}
```
### Type definitions
```elixir
_iex> use Tagged.Status
_iex> t Tagged.Status.error
@type error() :: {:error, term()}
Tagged value tuple, containing term().
```
### Selective execution with unwrapped value
```elixir
iex> use Tagged.Status
iex> ok(:computer) |> with_ok(& "OK, #{&1}")
"OK, computer"
```
## Installation
The package can be installed by adding `tagged` to your list of dependencies
in `mix.exs`:
```elixir
def deps do
[
{:tagged, "~> 0.3.0"}
]
end
```