How might I access the definition of a typespec within my code? I wish to use it within a macro in order to perform some code generation.
Something like this would be ideal.
Given this module and typespec:
defmodule MyMod do
@type t :: :ok | :error
end
I could call a function such as Code.get_type(MyMod, :t)
and it would return the AST of the definition expression:
{:::, [], [{:my_type, [], Elixir}, {:|, [], [:ok, :error]}]}
Or alternatively just the AST of the type:
{:|, [], [:ok, :error]}
Aucun commentaire:
Enregistrer un commentaire