sealed trait Syntax
case class Num(value: Long) extends Syntax
case class Add[A, B](left: A, right: B) extends Syntax
trait Construct[A] {
type S <: Syntax
def reduce(a: A): S
}
implicit def addConstruct[A, B](implicit lc: Construct[A], rc: Construct[B]) = new Construct[Add[A, B]] {
override type S <: ???
override def reduce(a: Add[A, B]): S = a match {
case Something1 => Add(lc.reduce(left), right) // returning Add
case Something2 => Add(left, rc.reduce(right)) // returning Add
case Something3 => Num(x + y) // returning Num
}
}
> email to shapeless-dev+unsubscribe@googlegroups.com.
--
Miles Sabin
tel: +44 7813 944 528
skype: milessabin
gtalk: mi...@milessabin.com
http://milessabin.com/blog
http://twitter.com/milessabin
--
You received this message because you are subscribed to the Google Groups "Shapeless Dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shapeless-dev+unsubscribe@googlegroups.com.