Typle.Inference (Typle v0.3.1)

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

expr_map()

@type expr_map() :: %{required({non_neg_integer(), non_neg_integer()}) => String.t()}

inference_result()

@type inference_result() :: %{types: type_map(), exprs: expr_map()}

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, inference_result()} | {:error, term()}

Infers types for all expressions in the given source file.

Returns {:ok, %{types: type_map, exprs: expr_map}} where type_map maps {line, col} to types and expr_map maps positions to source expression strings.

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, inference_result()} | {: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)