How to get anonymous function from its type?

For singleton types (such as anonymous functions which aren’t closures), you can access the instance from the instance field:

julia> f = x -> x + 1
#1 (generic function with 1 method)

julia> T = typeof(f)
var"#1#2"

julia> T.instance
#1 (generic function with 1 method)
6 Likes