Accepted answer

First of all, solving something for tuples of any arity in Scala is nasty because the tuple classes are distinct, so you'd have to have 8 or 22 or whatever arity you want to support conversions.

But anyways, tuples are for heterogeneously typed things, whereas you here require a collection of a common type. So while tuple syntax may look nice, I would recommend not to try to use it for this case in your DSL. Stick to collections or just alias your Group type, even at the price of an additional character, e.g.

object A {
  implicit def fromString(name: String) = A(name)
case class A(name: String)
case class Group(elem: A*)

val G = Group
G("a1", "a2")

If you really want to support tuples, the following will do:

object Group {
  implicit def fromTuple2[A1 <% A, A2 <% A](t: (A1, A2)) = Group(t._1, t._2)
case class Group(elem: A*)

("a1", "a2"): Group

Related Query

More Query from same tag