title: How can I use Shapeless to create a function abstracting over arity
body: <p>Let's consider a specific example. I have lots of functions that take a variable number of arguments, and return a <code>Seq[T]</code>. Say:</p>
  
  <pre><code>def nonNeg(start: Int, count: Int): Seq[Int] = 
      Iterator.from(start).take(count).toSeq
  </code></pre>
  
  <p>For each one of those function, I need to create a "Java version" of that function, returns a <code>java.util.List[T]</code>. I can create the "Java version" of the above function with:</p>
  
  <pre><code>def javaNonNeg(start: Int, count: Int): java.util.List[Int] =
      nonNeg(start, count).asJava
  </code></pre>
  
  <p>This is somewhat verbose, as the list of parameters is duplicated twice. Instead, I'd like to create a higher level function that takes as a parameter a function of the form of <code>nonNeg</code> (any number and type of arguments, returns a <code>Seq[T]</code>) and returns a function which takes the same arguments, but returns a <code>java.util.List[T]</code>. Assuming that function was called <code>makeJava</code>, I'd then be able to write:</p>
  
  <pre><code>def javaNonNeg = makeJava(nonNeg)
  </code></pre>
  
  <p>Can <code>makeJava</code> be written using <a href="https://github.com/milessabin/shapeless/">Shapeless</a> ability to <a href="https://github.com/milessabin/shapeless/wiki/Feature-overview:-shapeless-2.0.0#facilities-for-abstracting-over-arity">abstracting over arity</a>? If it can, how, and it not, why and how else can this be done?</p>