Smoothing a class hierarchy of a private class

Suppose I have a private case class hierarchy, such as:

sealed trait Expr case class Const(val: Double) extends Expr case class Plus(x: Expr, y: Expr) extends Expr case class Times(x: Expr, y: Expr) extends Expr 
  • Is it possible to automatically convert expressions like Plus(1,Plus(2,3)) into HLists from HLists?
  • Will the conversion work even inside some function f(e: Expr) , i.e. when is a particular e structure unknown at compile time?
+6
source share
1 answer

It turns out that SO has already been answered here and that there is a corresponding example in the Shapeless distribution from shapeless-2.1.0-SNAPSHOT.

0
source

All Articles