title: In Scala, can generic type parameters be used with *function* definitions?
body: <p>Is there a syntax to allow generic type parameters on function literals? I know I could wrap it in a method such as:</p>
  
  <pre><code>def createLongStringFunction[T](): (T) =&gt; Boolean = {
    (obj: T) =&gt; obj.toString.length &gt; 7
  }
  </code></pre>
  
  <p>but then I end up needing to invoke the method for every type T and getting a new function. I looked through the language reference, and while I see that the function literal syntax is translated by the compiler to an instance of a <em>Functionn</em> object that itself has generic input types, it looks like the compiler magic realizes those parameters at the time of creation. I haven't found any syntax that allows me to, in effect, "leave one or more of the type parameters of <em>Functionn</em> unbound". What I would prefer is something along the lines of:</p>
  
  <pre><code>// doesn't compile
  val longStringFunction: [T](T) =&gt; Boolean = (obj: T) =&gt; obj.toString.length &gt; 7
  </code></pre>
  
  <p>Does any such thing exist? Or for that matter, what is the explicit type of an eta-expansion function when the method being expanded has generic parameters?</p>
  
  <p>This is a purely contrived and useless example. Of course I could just make the function use Any here.</p>