Ivoking a macro within a @type on the right side of `::`

Hi,
I am tying to define a type with a macro,

So far I have
deftype(:foo, [:true, :false, :nil])

which generates
@type foo :: true | false | nil
and works fine

But what I am trying to do is to simplify the usage and make it more natural to Elxiir syntax.
Is there a way I can call a macro only for the return value of the type without it being evaluated as a type, such as in this hypothetical code:

@type foo :: type_return([:true, :false, :nil])

Cheers

1 Like

I tried:

  quote do
    @type foo :: unquote(TypeEvaluator.return_value())
  end

being the Macro:

  defmacro return_value() do
    quote do
      atom()
    end
  end

but I get this error,

== Compilation error in file lib/bar.ex ==
** (CompileError) lib/bar.ex:25: undefined function atom/0 (there is no such import)
    expanding macro: ExtendedTypes.TypeEvaluator.return_value/0
    lib/bar.ex:25: Bar (module)

Is there a way to delay the evaluation of the macro?

1 Like