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 {
5252 }
5353 }
5454
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+
5562 given [T : Type : Liftable ] as Liftable [List [T ]] = new Liftable [List [T ]] {
5663 def toExpr (x : List [T ]): given QuoteContext => Expr [List [T ]] = x match {
5764 case x :: xs => ' { ($ {xs.toExpr}).:: [T ]($ {x.toExpr}) }
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ object Test {
2929 val list : List [Int ] = List (1 , 2 , 3 )
3030 val liftedList : Expr [List [Int ]] = list
3131
32+ val seq : Seq [Int ] = Seq (1 , 2 , 3 )
33+ val liftedSeq : Expr [Seq [Int ]] = seq
34+
3235 liftedList.foldLeft[Int ](0 )(' { (acc : Int , x : Int ) => acc + x }).show
3336 liftedList.foreach(' { (x : Int ) => println(x) }).show
3437
You can’t perform that action at this time.
0 commit comments