# On types of functions

**URL:** https://discourse.julialang.org/t/on-types-of-functions/66058
**Category:** General Usage
**Created:** [August 9, 2021, 6:22am UTC](https://discourse.julialang.org/t/on-types-of-functions/66058 "2021-08-09T06:22:40Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Judd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/judd/32/27866_2.png) [@Judd](https://discourse.julialang.org/u/Judd)
#### Post date: [August 9, 2021, 6:22am UTC](https://discourse.julialang.org/t/on-types-of-functions/66058/1 "2021-08-09T06:22:41Z")

</div>

I propose to add a subsection “Type of Functions” to Manual / Types. This will be very helpful, especially for newcomers to learn the essentials of Julia types and functions. If anything wrong, please correct me.

> ## Types of Functions
> 
> Each function has its own type, which is both concrete and singleton, and with Function as its supertype.
> 
> Recall that a function is consisted by one or more methods, therefore, a function could not have a similar type signature as in other programming languages, such as C, Haskell, etc.

---

<div class="post-metadata">

### Author: ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)
#### Post date: [August 9, 2021, 6:29am UTC](https://discourse.julialang.org/t/on-types-of-functions/66058/2 "2021-08-09T06:29:53Z")

</div>

You can actually have a function with no methods

```julia
julia> function foo end
foo (generic function with 0 methods)

```

but you can also specify signatures in Julia. A single syntax can create both a function and a method:

```julia
julia> (double(x::Integer)::Integer) = 2x
double (generic function with 1 method)

```

but that signature isn’t included in the type of the function, as you say. Though there have been discussions about whether it should. I personally would like to have a way of expressing the type of a function that takes Integer to Integer without specifying which particular function it is.

---

<div class="post-metadata">

### Author: ![Judd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/judd/32/27866_2.png) [@Judd](https://discourse.julialang.org/u/Judd)
#### Post date: [August 9, 2021, 6:39am UTC](https://discourse.julialang.org/t/on-types-of-functions/66058/3 "2021-08-09T06:39:39Z")

</div>

Thanks. A revised version:

> ## Types of Functions
> 
> Each function has its own type, which is both concrete and singleton, and with Function as its supertype.
> 
> Recall that a function is consisted by methods, therefore, a function can not have a similar type signature as in other programming languages, while a method can.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [August 10, 2021, 11:58am UTC](https://discourse.julialang.org/t/on-types-of-functions/66058/4 "2021-08-10T11:58:28Z")

</div>

Thanks for bringing up this issue, I made a PR for the docs:

[https://github.com/JuliaLang/julia/pull/41855](https://github.com/JuliaLang/julia/pull/41855)

(Incidentally, note that anonymous functions may not be singletons, I added an example).
