Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><a href="https://github.com/milessabin/shapeless" rel="noreferrer">Shapeless</a> requires dependent method types (<code>-Ydependent-method-types</code>) and I wish there was a downloadable binary for 2.9.1 so that I can simply try it out but it's really seems elegant. Based on <a href="https://github.com/milessabin/shapeless/blob/master/src/test/scala/shapeless/conversions.scala" rel="noreferrer">this unit test</a> it would apply to your case like this:</p> <pre><code>import shapeless.Tuples._ import shapeless.HList._ val t7 = (t1.hlisted ::: t2.hlisted ::: t3.hlisted).tupled </code></pre> <p>Although Miles indicates there is not guarantee of support, it actually has unit tests and the source is on github with an open source license so at least it's not just an experiment in a blog post.</p> <p>Edit: works as advertized - took some time to compile and I had to add <code>-Xss1m</code> to sbt:</p> <pre><code>$ scala -Ydependent-method-types -cp target/scala-2.9.1/shapeless_2.9.1-1.1.0.jar Welcome to Scala version 2.9.1.final (Java HotSpot(TM) Client VM, Java 1.7.0). Type in expressions to have them evaluated. Type :help for more information. scala&gt; import shapeless.Tuples._ import shapeless.Tuples._ scala&gt; import shapeless.HList._ import shapeless.HList._ scala&gt; val t1 = Tuple2("abcd", "efg") t1: (java.lang.String, java.lang.String) = (abcd,efg) scala&gt; val t2 = Tuple2(1234, "lmnop") t2: (Int, java.lang.String) = (1234,lmnop) scala&gt; val t3 = Tuple3("qrs", "tuv", "wxyz") t3: (java.lang.String, java.lang.String, java.lang.String) = (qrs,tuv,wxyz) scala&gt; (t1.hlisted ::: t2.hlisted ::: t3.hlisted).tupled res0: (java.lang.String, java.lang.String, Int, java.lang.String, java.lang.String, java.lang.String, java.lang.String) = (abcd,efg,1234,lmnop,qrs,tuv,wxyz) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload