File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -52,6 +52,13 @@ object Liftable {
52
52
}
53
53
}
54
54
55
+ given [T : Type : Liftable ] as Liftable [Seq [T ]] = new Liftable [Seq [T ]] {
56
+ def toExpr (seq : Seq [T ]): given QuoteContext => Expr [Seq [T ]] = given qctx => {
57
+ import qctx .tasty ._
58
+ Repeated (seq.map(x => the[Liftable [T ]].toExpr(x).unseal).toList, the[quoted.Type [T ]].unseal).seal.asInstanceOf [Expr [Seq [T ]]]
59
+ }
60
+ }
61
+
55
62
given [T : Type : Liftable ] as Liftable [List [T ]] = new Liftable [List [T ]] {
56
63
def toExpr (x : List [T ]): given QuoteContext => Expr [List [T ]] = x match {
57
64
case x :: xs => ' { ($ {xs.toExpr}).:: [T ]($ {x.toExpr}) }
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ object Test {
29
29
val list : List [Int ] = List (1 , 2 , 3 )
30
30
val liftedList : Expr [List [Int ]] = list
31
31
32
+ val seq : Seq [Int ] = Seq (1 , 2 , 3 )
33
+ val liftedSeq : Expr [Seq [Int ]] = seq
34
+
32
35
liftedList.foldLeft[Int ](0 )(' { (acc : Int , x : Int ) => acc + x }).show
33
36
liftedList.foreach(' { (x : Int ) => println(x) }).show
34
37
You can’t perform that action at this time.
0 commit comments