How to get a function instance from a function type?

No, because not all functions have a one-to-one relationship with their types. For instance,

f = let x = 1
   y -> x + y
end

captures runtime data and cannot be reconstructed from it’s type alone.

That said, in the case of functions which are singleton instances, you could do

if isdefined(tf, :instance)
    ft.instance
else
    error("This type does not have a single instance")
end
1 Like