I have a list of macros in Elixir and trying to put quotes around it, please help me.
I want to convert [Id, Node, Timestamp] into "[Id, Node, Timestamp]".
How would I do that?
[Id, Node, Timestamp] is a list of atoms not a list of macros.
Atoms are plain terms and hence plain old good Kernel.inspect/2 would perfectly do.
inspect [Id, Node, Timestamp]
#⇒ "[Id, Node, Timestamp]"
If you have a quoted expression, I believe Macro.to_string/2 is what you're looking for.
iex> ast = quote do: [Id, Node, Timestamp]
[Id, Node, Timestamp]
iex> Macro.to_string(ast)
"[Id, Node, Timestamp]"
Like Aleksei pointed out, however, the AST for a list of atoms is itself, so if that's all you're trying to convert to a string, Kernel.inspect/2 accomplishes the same thing.
Macro.to_string([Id, Node, Timestamp]) has the same effect.