Typle.SignatureStore (Typle v0.1.0)

View Source

ETS-backed cache of function type signatures.

Pre-loads function signatures from compiled .beam files for the project and all dependencies. Used by the inference engine to look up return types for remote function calls.

Summary

Functions

Clears all cached signatures.

Initializes the signature store. Creates the ETS table if it does not exist.

Loads signatures for a single module.

Loads signatures for all .beam files found under build_path.

Looks up the signature clauses for module.function/arity.

Given concrete argument types, finds the best matching clause and returns its return type. Falls back to dynamic() if no clause matches.

Functions

clear()

@spec clear() :: :ok

Clears all cached signatures.

init()

@spec init() :: :ok

Initializes the signature store. Creates the ETS table if it does not exist.

load_module(module)

@spec load_module(module()) :: :ok | {:error, term()}

Loads signatures for a single module.

load_project(build_path)

@spec load_project(String.t()) :: {:ok, non_neg_integer()} | {:error, term()}

Loads signatures for all .beam files found under build_path.

Typically called with Mix.Project.build_path() to load the current project and its dependencies.

lookup(module, function, arity)

@spec lookup(module(), atom(), non_neg_integer()) ::
  {:ok, [{[Typle.Type.t()], Typle.Type.t()}]} | :error

Looks up the signature clauses for module.function/arity.

return_type(module, function, arity, arg_types)

@spec return_type(module(), atom(), non_neg_integer(), [Typle.Type.t()]) ::
  Typle.Type.t()

Given concrete argument types, finds the best matching clause and returns its return type. Falls back to dynamic() if no clause matches.