View Source FreeVarAnalysis (Chorex v0.8.4)

Free variable analysis for Elixir expressions

Summary

Types

@type ast() :: any()
@type full_var() :: {atom(), any(), atom()}

Functions

Collect all variables mentioned in some syntax, free or otherwise.

iex> all_vars(quote do: x) |> Enum.map(&elem(&1, 0)) [:x] iex> all_vars(quote do: fn x -> x + 1 end) |> Enum.map(&elem(&1, 0)) [:x] iex> all_vars(quote do: fn x -> x + y end) |> Enum.map(&elem(&1, 0)) [:x, :y]

Link to this function

extract_new_pattern_var_names(expr, bound \\ MapSet.new())

View Source
Link to this function

extract_pattern_vars(expr, bound \\ MapSet.new())

View Source
@spec extract_pattern_vars(expr :: ast(), bound :: MapSet.t()) ::
  {free_vars :: [full_var()], new_bindings :: [full_var()]}
Link to this function

free_vars(stx, bound \\ MapSet.new())

View Source

Return all variables that are free in an expression.

iex> freevars(quote do: fn x -> {^x, ^y, } = {1, 2, 3} end) |> Enum.map(&elem(&1, 0)) [:y]