# `SpecLint.Typespec`
[🔗](https://github.com/lukaszsamson/spec_lint/blob/v0.1.0/lib/spec_lint/typespec.ex#L1)

Internal, unstable compiler translator; not a supported public API.

Translates typespec ASTs (as returned by <code>Code.Typespec</code>) into the
compiler's own types (<code>Module.Types.Descr</code>).

Every translation is `{descr, exact?}`. The lattice cannot express integer
ranges, sized binaries, charlists as strings and a few other refinements;
those are widened and flagged inexact. An inexact translation always
over-approximates the spec, never under-approximates it, so a
disjointness proven against the translation holds for the real spec.

# `translated`

```elixir
@type translated() :: {term(), boolean()}
```

A translated type: the descr and whether it is exact.

# `spec`

```elixir
@spec spec(tuple(), module()) ::
  {:ok, [translated()], translated()} | {:error, term()}
```

Translates one spec clause of `module`: `{:ok, args, return}` with one
translation per argument and one for the return, or `:error` when the
clause uses a construct with no sound translation (a constraint other
than `when x: type`, an unknown built-in), with the construct as the
reason. A named type that cannot be read is `term()`, inexact.

# `type`

```elixir
@spec type(tuple(), module()) :: {:ok, translated()} | {:error, term()}
```

Translates one type AST in the context of `module`.

---

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