vfclists
vfclists

Reputation: 20241

Is there a tool in Elixir that can display a break down of how an expression is evaluated?

I have this one-liner from this question - What is the correct syntax for this Elixir expression?.

|> (fn l ->[?[, Enum.map(l, &([inspect(&1, limit: :infinity), ?\n])) \
|> Enum.intersperse(?,), ?]] end).()

Is there a tool in Elixir that can display a breakdown of how it is evaluated?

Upvotes: 0

Views: 68

Answers (1)

Dogbert
Dogbert

Reputation: 222348

Since the main problem you face seems to be in recognizing what the arguments to a parentheses-less function call are in complex expressions, you can parse a string to Elixir AST (Code.string_to_quoted!/1) and back (Macro.to_string/1), which will add explicit parentheses wherever there's a function call.

iex(1)> "a B.c |> D.e + f g h + i" |> Code.string_to_quoted! |> Macro.to_string
"a(B.c() |> D.e() + f(g(h + i)))"

Upvotes: 1

Related Questions