Typle.Inference (Typle v0.3.0)

View Source

Orchestrates type inference for a module or file.

Parses the source file, expands macros in function bodies via Typle.Inference.Expander (powered by ExPanda), then walks each function definition through the expression inference engine. Collects a map of {line, col} => Typle.Type.t() for every expression in the module.

Summary

Functions

Infers types for all expressions in the given source file.

Infers types for all expressions in a compiled module.

Types

type_map()

@type type_map() :: %{
  required({non_neg_integer(), non_neg_integer()}) => Typle.Type.t()
}

Functions

infer_file(file_path, opts \\ [])

@spec infer_file(
  String.t(),
  keyword()
) :: {:ok, type_map()} | {:error, term()}

Infers types for all expressions in the given source file.

Returns a map of {line, col} => type for each expression node that has position metadata.

Options

  • :unstable - when true, uses the compiler-replay engine from Typle.Unstable for deeper inference (default: false)

infer_module(module, opts \\ [])

@spec infer_module(
  module(),
  keyword()
) :: {:ok, type_map()} | {:error, term()}

Infers types for all expressions in a compiled module.

Locates the source file from the module's compile info and delegates to infer_file/1.

Options

  • :unstable - when true, uses the compiler-replay engine from Typle.Unstable for deeper inference (default: false)