Scala type inference is really nice and it is easy to get used not to have to write things twice. The more it hurts when you have to. One such example are function types.
Sometimes I would like to create a named type for some function signature. Is it possible somehow? Is there some way to get the compile-time type of the function so that I do not have to type it again when defining FType
?
object Foo {
def f(a:Int, b:Int, x:Double, y:Double, name:String) : Unit = {}
//type FType = typeOf(f) // can compiler provide me a compile time type somehow?
type FType = (Int,Int,Double,Double,String) => Unit
def callF( func:FType) = func(0,0,0,0,"")
}
Is there something like C++ decltype in Scala which could be used for this purpose?