View Source Kinda.CodeGen.TypeSpecRef (kinda v0.11.0)

A small embedded DSL describing typespecs in declaration manifests.

Typespecs are plain terms: builtins (:term, :integer, ...), remote module types, lists, maps, tuples and unions. to_quoted/1 lowers them into quoted Elixir typespecs, and to_manifest/1 / from_manifest/1 round-trip them through the JSON-compatible manifest format.

Summary

Types

builtin()

@type builtin() :: :term | :integer | :float | :boolean | :binary | :atom | :ok

map_key()

@type map_key() :: atom() | String.t()

t()

@type t() ::
  builtin()
  | {:remote, module(), atom()}
  | {:list, t()}
  | {:map, [{map_key(), t()}]}
  | {:tuple, [t()]}
  | {:union, [t()]}

Functions

atom()

@spec atom() :: :atom

binary()

@spec binary() :: :binary

boolean()

@spec boolean() :: :boolean

float()

@spec float() :: :float

from_manifest(map)

@spec from_manifest(map()) :: t()

integer()

@spec integer() :: :integer

list(inner)

@spec list(t()) :: {:list, t()}

map(fields)

@spec map([{map_key(), t()}]) :: {:map, [{map_key(), t()}]}

ok()

@spec ok() :: :ok

remote(module, type_name \\ :t)

@spec remote(module(), atom()) :: {:remote, module(), atom()}

term()

@spec term() :: :term

to_manifest(arg1)

@spec to_manifest(t()) :: map()

to_quoted(arg1)

@spec to_quoted(t()) :: Macro.t()

tuple(elements)

@spec tuple([t()]) :: {:tuple, [t()]}

union(types)

@spec union([t()]) :: {:union, [t()]}