Typle.ExprMap (Typle v0.3.1)

View Source

Post-hoc expression extraction from source files.

Parses the original (unexpanded) AST and walks it to build a map of {line, col} => expression_string for every AST node that carries position metadata.

This is primarily used by the unstable inference path, which captures types via compiler replay but has no access to expression strings.

Summary

Functions

Looks up the expression string at {line, col} in a source file.

Extracts a map of {line, col} => expression_string from a source file.

Types

expr_map()

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

Functions

expr_at(file_path, line, col)

@spec expr_at(String.t(), non_neg_integer(), non_neg_integer()) :: String.t() | nil

Looks up the expression string at {line, col} in a source file.

Returns nil when no AST node starts at that position.

extract(file_path)

@spec extract(String.t()) :: {:ok, expr_map()} | {:error, term()}

Extracts a map of {line, col} => expression_string from a source file.

Parses the file without macro expansion and records Macro.to_string/1 for each AST node that has :line and :column metadata.