Theoria.Equation.Matcher.Descriptor (theoria v0.7.0)

Copy Markdown View Source

Experimental/internal API for 0.2; subject to change before 0.3. Internal descriptor-driven matcher generation metadata.

Summary

Functions

Returns normalized field types for an alternative.

Returns the normalized field name.

Returns the normalized field type.

Builds a matcher descriptor from checked recursor metadata when an environment is available.

Builds a matcher descriptor from schema, matcher metadata, and recursor shape metadata.

Builds a matcher descriptor from schema and matcher metadata.

Returns whether a normalized field is recursive.

Validates descriptor consistency against matcher metadata.

Types

t()

@type t() :: %Theoria.Equation.Matcher.Descriptor{
  alternatives: [Theoria.Equation.Matcher.Descriptor.Alternative.t()],
  discriminants: [Theoria.Equation.Matcher.Info.Discriminant.t()],
  family: atom(),
  indexed?: boolean(),
  indices: [{atom(), Theoria.Term.t()}],
  parameters: [{atom(), Theoria.Term.t()}],
  recursive?: boolean(),
  recursor: atom(),
  recursor_descriptor: Theoria.Equation.Recursor.Descriptor.t() | nil,
  result: Theoria.Term.t()
}

Functions

alternative_field_types(alternative)

@spec alternative_field_types(Theoria.Equation.Matcher.Descriptor.Alternative.t()) ::
  [Theoria.Term.t()]

Returns normalized field types for an alternative.

field_name(field)

Returns the normalized field name.

field_type(field)

Returns the normalized field type.

from_env(env, schema, info)

@spec from_env(
  Theoria.Env.t(),
  Theoria.Equation.Schema.t(),
  Theoria.Equation.Matcher.Info.t()
) ::
  {:ok, t()} | {:error, term()}

Builds a matcher descriptor from checked recursor metadata when an environment is available.

from_recursor(schema, info, recursor)

Builds a matcher descriptor from schema, matcher metadata, and recursor shape metadata.

from_schema(schema, info)

@spec from_schema(Theoria.Equation.Schema.t(), Theoria.Equation.Matcher.Info.t()) ::
  {:ok, t()} | {:error, term()}

Builds a matcher descriptor from schema and matcher metadata.

recursive_field?(field)

@spec recursive_field?(Theoria.Equation.Matcher.Descriptor.Field.t()) :: boolean()

Returns whether a normalized field is recursive.

validate(descriptor, info)

@spec validate(t(), Theoria.Equation.Matcher.Info.t()) :: :ok | {:error, term()}

Validates descriptor consistency against matcher metadata.