Full documentation is on hexdocs.pm
A library to work with tagged tuples.
Tagged tuple is a tuple attaching a tag to a value {tag, value}
.
Common tagged tuples are {:ok, value}
and {:error, message}
returned
from the functions.
A chain of tags can be attached to a single core value by nesting tagged tuples in each other.
For example, {:units, {:boxes, 1}}
and {:units, {:kilograms, 2.5}}
tagged tuples describe the same deliverable item with different measures.
The tag chains of :units
--- :boxes
and :units
--- :kilograms
can be efficiently pattern matched then to handle core values of
different types appropriately.
iex> use TaggedTuple
...> :tag --- 12
{:tag, 12}
...> tagged_tuple = :a --- :tag --- :chain --- 12
{:a, {:tag, {:chain, 12}}}
...> match?(:a --- :tag --- _tail, tagged_tuple)
true
...> :a --- t1 --- t2 --- core_value = tagged_tuple
...> t1 == :tag
...> t2 == :chain
...> core_value == 12
- Inintial release
Copyright © 2021 Ivan Rublev
This project is licensed under the MIT license.