# `Macaw.Layers.Vocabulary`
[🔗](https://github.com/dcoai/macaw_layers/blob/v0.2.2/lib/macaw/layers/vocabulary.ex#L1)

A closed vocabulary read from a string (spec/01 §2).

A table maps each member's spelling to the member, built from the vocabulary's own list.
A reader looks a document's string up in it and never makes an atom of one. Nor does it
ask the node whether such an atom exists (`String.to_existing_atom/1`), which would let a
document probe the atom table and make a read depend on which modules are loaded. A
string the table lacks is the caller's to refuse at its path.

Build a table once, in a module attribute, wherever the list is known at compile time:

    @anchors Vocabulary.table([:title, :subtitle, :caption])
    Vocabulary.fetch(@anchors, "title")   #=> {:ok, :title}
    Vocabulary.fetch(@anchors, "footer")  #=> :error

Ported from visualize's `Visualize.Vocabulary`.

# `table`

```elixir
@type table() :: %{required(String.t()) =&gt; atom()}
```

A vocabulary's members by their spelling.

# `fetch`

```elixir
@spec fetch(table() | [atom()], term()) :: {:ok, atom()} | :error
```

The member a string spells, from a table or, for a list known only at run time and a few
members long, from the list itself. Anything that is not a string is `:error`.

# `read`

```elixir
@spec read(table() | [atom()], String.t()) :: atom() | String.t()
```

The member a string spells, or the string itself: a value a validator then refuses by
type at its path.

# `table`

```elixir
@spec table([atom()]) :: table()
```

The table of a list of atoms.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
