In order to deal with the case where you specify the value of each instances, you may use:
julia> module A
macro exported_enum(T, syms...)
return esc(quote
@enum($T, $(syms...))
export $T
for inst in Symbol.(instances($T))
eval($(Expr(:quote, :(export $(Expr(:$, :inst))))))
end
end)
end
@exported_enum fruit apple=2 banana=3
end
Main.A
julia> using Main.A
julia> fruit
Enum fruit:
apple = 2
banana = 3