ToolCall.TypeExpr (ToolCall v0.4.0)

Copy Markdown

Source-neutral, unresolved type expressions for ToolCall.TypeCompiler.

A TypeExpr describes type shape, local references, remote/provider boundaries, and value-domain annotations. It deliberately does not carry ToolCall.IR.Type wire metadata such as transforms, validators, or JSON Schema refs; TypeCompiler resolves those later.

:local_ref is an intermediate index produced during local-type expansion; rewrite_refs turns it into a named :ref.

Summary

Functions

The empty type.

Validates the shape of a type expression.

Types

field()

@type field() :: {atom(), t(), boolean()}

t()

@type t() ::
  :any
  | :none
  | {:literal, term()}
  | {:primitive, :boolean | :integer | :float | :number | :string | :atom}
  | {:integer_range, integer() | nil, integer() | nil}
  | {:enum, [term()]}
  | {:string, map()}
  | {:list, t()}
  | {:nonempty_list, t()}
  | {:tuple, [t()] | nil}
  | {:map, [field()], t() | nil}
  | {:union, [t()]}
  | {:intersection, [t()]}
  | {:negation, t()}
  | {:var, atom()}
  | {:ref, String.t()}
  | {:ref, {atom(), non_neg_integer()}, [t()]}
  | {:local_ref, non_neg_integer()}
  | {:remote, module(), atom(), [t()]}
  | {:builtin, atom(), [t()]}
  | {:dynamic, t()}
  | {:unsupported, term()}
  | {:annotated, t(), map()}

Functions

none()

@spec none() :: :none

The empty type.

validate(expression)

@spec validate(t()) :: :ok | {:error, String.t()}

Validates the shape of a type expression.

This checks the structure a source is allowed to produce, not whether the type has a JSON representation. It is called at the source/compiler boundary so a malformed nested expression becomes an :unsupported IR node instead of a crash.