Note that for anyone reading through this statement is false. Functions are not always singleton types, and are thus should not be assumed to be a subset of “all singleton types”. In fact, all objects are can be used as function arguments, so Any object may be given there.
Most of the “solutions” presented here are wrong: you should never need to access “.instance”. This is an internal API and not stable. The correct way to do this is to store the actual function object itself, and always refer to it by value and don’t try to do this in the type-domain. Adopting the original example, we get the much-shortened:
julia> struct MyStruct{F}
f::F
end
julia> ExtractFun(s::MyStruct) = s.f