# How to get a function instance from a function type?

**URL:** https://discourse.julialang.org/t/how-to-get-a-function-instance-from-a-function-type/79585
**Category:** Internals & Design
**Tags:** type, function
**Created:** [April 17, 2022, 1:52am UTC](https://discourse.julialang.org/t/how-to-get-a-function-instance-from-a-function-type/79585 "2022-04-17T01:52:09Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Mason](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mason/32/2423_2.png) [@Mason](https://discourse.julialang.org/u/Mason)
#### Post date: [April 17, 2022, 3:32am UTC](https://discourse.julialang.org/t/how-to-get-a-function-instance-from-a-function-type/79585/2 "2022-04-17T03:32:08Z")

</div>

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

```julia
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

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

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-get-a-function-instance-from-a-function-type/79585)._
