@@ -60,40 +60,40 @@ package liftable {
60
60
61
61
object Lets {
62
62
def letVal [T , U : Type ](expr : Expr [T ])(body : Expr [T ] => Expr [U ])(implicit t : Type [T ]): Expr [U ] =
63
- ' { val letVal : ~ t = ~ expr; ~ body(' {letVal}) }
63
+ ' { val letVal : $ t = $ expr; $ { body(' {letVal}) } }
64
64
def letLazyVal [T , U : Type ](expr : Expr [T ])(body : Expr [T ] => Expr [U ])(implicit t : Type [T ]): Expr [U ] =
65
- ' { lazy val letLazyVal : ~ t = ~ expr; ~ body(' {letLazyVal}) }
65
+ ' { lazy val letLazyVal : $ t = $ expr; $ { body(' {letLazyVal}) } }
66
66
def letDef [T , U : Type ](expr : Expr [T ])(body : Expr [T ] => Expr [U ])(implicit t : Type [T ]): Expr [U ] =
67
- ' { def letDef : ~ t = ~ expr; ~ body(' {letDef}) }
67
+ ' { def letDef : $ t = $ expr; $ { body(' {letDef}) } }
68
68
}
69
69
70
70
object Loops {
71
- def liftedWhile (cond : Expr [Boolean ])(body : Expr [Unit ]): Expr [Unit ] = ' { while (~ cond) ~ body }
72
- def liftedDoWhile (body : Expr [Unit ])(cond : Expr [Boolean ]): Expr [Unit ] = ' { do ~ body while (~ cond) }
71
+ def liftedWhile (cond : Expr [Boolean ])(body : Expr [Unit ]): Expr [Unit ] = ' { while ($ cond) $ body }
72
+ def liftedDoWhile (body : Expr [Unit ])(cond : Expr [Boolean ]): Expr [Unit ] = ' { do $ body while ($ cond) }
73
73
}
74
74
75
75
object Tuples {
76
76
77
77
implicit def Tuple1IsLiftable [T1 : Liftable ](implicit t1 : Type [T1 ]): Liftable [Tuple1 [T1 ]] = new Liftable [Tuple1 [T1 ]] {
78
78
def toExpr (x : Tuple1 [T1 ]): Expr [Tuple1 [T1 ]] =
79
- ' { Tuple1 [~ t1](~ x._1.toExpr) }
79
+ ' { Tuple1 [$ t1]($ { x._1.toExpr} ) }
80
80
}
81
81
82
82
implicit def Tuple2IsLiftable [T1 : Liftable , T2 : Liftable ](implicit t1 : Type [T1 ], t2 : Type [T2 ]): Liftable [(T1 , T2 )] = new Liftable [(T1 , T2 )] {
83
83
def toExpr (x : (T1 , T2 )): Expr [(T1 , T2 )] =
84
- ' { Tuple2 [~ t1, ~ t2](~ x._1.toExpr, ~ x._2.toExpr) }
84
+ ' { Tuple2 [$ t1, $ t2]($ { x._1.toExpr}, $ { x._2.toExpr} ) }
85
85
86
86
}
87
87
88
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
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}) }
90
+ ' { Tuple3 [$t1, $ t2, $ t3]($ { x._1.toExpr}, $ { x._2.toExpr}, $ { x._3.toExpr}) }
91
91
92
92
}
93
93
94
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
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) }
96
+ ' { Tuple4 [$ t1, $ t2, $ t3, $ t4]($ { x._1.toExpr}, $ { x._2.toExpr}, $ { x._3.toExpr}, $ { x._4.toExpr} ) }
97
97
}
98
98
99
99
// TODO more tuples
@@ -104,32 +104,32 @@ package liftable {
104
104
object Lists {
105
105
implicit def ListIsLiftable [T : Liftable ](implicit t : Type [T ]): Liftable [List [T ]] = new Liftable [List [T ]] {
106
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] }
107
+ case x :: xs => ' { ($ { xs.toExpr} ).:: [$ t]($ { x.toExpr} ) }
108
+ case Nil => ' { Nil : List [$ t] }
109
109
}
110
110
}
111
111
112
112
implicit class LiftedOps [T : Liftable ](list : Expr [List [T ]])(implicit t : Type [T ]) {
113
113
def foldLeft [U ](acc : Expr [U ])(f : Expr [(U , T ) => U ])(implicit u : Type [U ]): Expr [U ] =
114
- ' { (~ list).foldLeft[~ u](~ acc)(~ f) }
114
+ ' { ($ list).foldLeft[$ u]($ acc)($ f) }
115
115
def foreach (f : Expr [T => Unit ]): Expr [Unit ] =
116
- ' { (~ list).foreach(~ f) }
116
+ ' { ($ list).foreach($ f) }
117
117
}
118
118
119
119
implicit class UnrolledOps [T : Liftable ](list : List [T ])(implicit t : Type [T ]) {
120
120
def unrolledFoldLeft [U ](acc : Expr [U ])(f : Expr [(U , T ) => U ])(implicit u : Type [U ]): Expr [U ] = list match {
121
- case x :: xs => xs.unrolledFoldLeft(' { (~ f).apply(~ acc, ~ x.toExpr) })(f)
121
+ case x :: xs => xs.unrolledFoldLeft(' { ($ f).apply($ acc, $ { x.toExpr} ) })(f)
122
122
case Nil => acc
123
123
}
124
124
def unrolledForeach (f : Expr [T => Unit ]): Expr [Unit ] = list match {
125
- case x :: xs => ' { ($ { f).apply($ {x.toExpr}} ); ~ xs.unrolledForeach(f) }
125
+ case x :: xs => ' { ($f).apply($ {x.toExpr}); $ { xs.unrolledForeach(f) } }
126
126
case Nil => ' {}
127
127
}
128
128
}
129
129
130
130
object Arrays {
131
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) }
132
+ def toExpr (arr : Array [T ]): Expr [Array [T ]] = ' { new Array [$ t]($ { arr.length.toExpr})($ ct) }
133
133
}
134
134
}
135
135
0 commit comments