@@ -53,7 +53,9 @@ package liftable {
5353  }
5454
5555  object  Units  {
56-     implicit  def  UnitIsLiftable :  Liftable [Unit ] =  _=>  ' { () }
56+     implicit  def  UnitIsLiftable :  Liftable [Unit ] =  new  Liftable [Unit ] {
57+       def  toExpr (x : Unit ):  Expr [Unit ] =  '()  
58+     }
5759  }
5860
5961  object  Lets  {
@@ -72,20 +74,26 @@ package liftable {
7274
7375  object  Tuples  {
7476
75-     implicit  def  Tuple1IsLiftable [T1 :  Liftable ](implicit  t1 : Type [T1 ]):  Liftable [Tuple1 [T1 ]] =  {
76-       case  Tuple1 (x1 : T1 ) =>  ' { Tuple1 [~ t1](~ x1.toExpr) }
77+     implicit  def  Tuple1IsLiftable [T1 :  Liftable ](implicit  t1 : Type [T1 ]):  Liftable [Tuple1 [T1 ]] =  new  Liftable [Tuple1 [T1 ]] {
78+       def  toExpr (x : Tuple1 [T1 ]):  Expr [Tuple1 [T1 ]] = 
79+         ' { Tuple1 [~ t1](~ x._1.toExpr) }
7780    }
7881
79-     implicit  def  Tuple2IsLiftable [T1 :  Liftable , T2 :  Liftable ](implicit  t1 : Type [T1 ], t2 : Type [T2 ]):  Liftable [(T1 , T2 )] =  {
80-       x =>  ' { Tuple2 [~ t1, ~ t2](~ x._1.toExpr, ~ x._2.toExpr) }
82+     implicit  def  Tuple2IsLiftable [T1 :  Liftable , T2 :  Liftable ](implicit  t1 : Type [T1 ], t2 : Type [T2 ]):  Liftable [(T1 , T2 )] =  new  Liftable [(T1 , T2 )] {
83+       def  toExpr (x : (T1 , T2 )):  Expr [(T1 , T2 )] = 
84+         ' { Tuple2 [~ t1, ~ t2](~ x._1.toExpr, ~ x._2.toExpr) }
85+ 
8186    }
8287
83-     implicit  def  Tuple3IsLiftable [T1 :  Liftable , T2 :  Liftable , T3 :  Liftable ](implicit  t1 : Type [T1 ], t2 : Type [T2 ], t3 : Type [T3 ]):  Liftable [(T1 , T2 , T3 )] =  {
84-       x =>  ' { Tuple3 [~ t1, ~ t2, ~ t3](~ x._1.toExpr, ~ x._2.toExpr, ~ x._3.toExpr) }
88+     implicit  def  Tuple3IsLiftable [T1 :  Liftable , T2 :  Liftable , T3 :  Liftable ](implicit  t1 : Type [T1 ], t2 : Type [T2 ], t3 : Type [T3 ]):  Liftable [(T1 , T2 , T3 )] =  new  Liftable [(T1 , T2 , T3 )] {
89+       def  toExpr (x : (T1 , T2 , T3 )):  Expr [(T1 , T2 , T3 )] = 
90+         ' { Tuple3 [~ t1, ~ t2, ~ t3](~ x._1.toExpr, ~ x._2.toExpr, ~ x._3.toExpr) }
91+ 
8592    }
8693
87-     implicit  def  Tuple4IsLiftable [T1 :  Liftable , T2 :  Liftable , T3 :  Liftable , T4 :  Liftable ](implicit  t1 : Type [T1 ], t2 : Type [T2 ], t3 : Type [T3 ], t4 : Type [T4 ]):  Liftable [(T1 , T2 , T3 , T4 )] =  {
88-       x =>  ' { Tuple4 [~ t1, ~ t2, ~ t3, ~ t4](~ x._1.toExpr, ~ x._2.toExpr, ~ x._3.toExpr, ~ x._4.toExpr) }
94+     implicit  def  Tuple4IsLiftable [T1 :  Liftable , T2 :  Liftable , T3 :  Liftable , T4 :  Liftable ](implicit  t1 : Type [T1 ], t2 : Type [T2 ], t3 : Type [T3 ], t4 : Type [T4 ]):  Liftable [(T1 , T2 , T3 , T4 )] =  new  Liftable [(T1 , T2 , T3 , T4 )] {
95+       def  toExpr (x : (T1 , T2 , T3 , T4 )):  Expr [(T1 , T2 , T3 , T4 )] = 
96+         ' { Tuple4 [~ t1, ~ t2, ~ t3, ~ t4](~ x._1.toExpr, ~ x._2.toExpr, ~ x._3.toExpr, ~ x._4.toExpr) }
8997    }
9098
9199    //  TODO more tuples
@@ -94,9 +102,11 @@ package liftable {
94102
95103
96104  object  Lists  {
97-     implicit  def  ListIsLiftable [T :  Liftable ](implicit  t : Type [T ]):  Liftable [List [T ]] =  {
98-       case  x ::  xs  =>  ' { (~ xs.toExpr).:: [~ t](~ x.toExpr) }
99-       case  Nil  =>  ' { Nil :  List [~ t] }
105+     implicit  def  ListIsLiftable [T :  Liftable ](implicit  t : Type [T ]):  Liftable [List [T ]] =  new  Liftable [List [T ]] {
106+       def  toExpr (x : List [T ]):  Expr [List [T ]] =  x match  {
107+         case  x ::  xs  =>  ' { (~ xs.toExpr).:: [~ t](~ x.toExpr) }
108+         case  Nil  =>  ' { Nil :  List [~ t] }
109+       }
100110    }
101111
102112    implicit  class  LiftedOps [T :  Liftable ](list : Expr [List [T ]])(implicit  t : Type [T ]) {
@@ -118,8 +128,8 @@ package liftable {
118128    }
119129
120130    object  Arrays  {
121-       implicit  def  ArrayIsLiftable [T :  Liftable ](implicit  t : Type [T ], ct : Expr [ClassTag [T ]]):  Liftable [Array [T ]] =  ( arr :  Array [T ])  =>   ' {
122-         new  Array [~ t](~ arr.length.toExpr)(~ ct)
131+       implicit  def  ArrayIsLiftable [T :  Liftable ](implicit  t : Type [T ], ct : Expr [ClassTag [T ]]):  Liftable [Array [T ]] =  new   Liftable [ Array [T ]]  {
132+         def   toExpr ( arr :  Array [ T ]) :   Expr [ Array [ T ]]  =   ' {  new  Array [~ t](~ arr.length.toExpr)(~ ct) } 
123133      }
124134    }
125135
0 commit comments