Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions library/src-3.x/scala/quoted/Type.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,20 @@ sealed abstract class Type[T <: AnyKind] {
/** Some basic type tags, currently incomplete */
object Type {

implicit class TypeOps[T](tpe: Type[T]) {
implicit object TypeOps {
/** Show a source code like representation of this type */
def show(implicit toolbox: Toolbox): String = toolbox.show(tpe.asInstanceOf[Type[Any]])
def (tpe: Type[T]) show[T] given Toolbox: String = the[Toolbox].show(tpe.asInstanceOf[Type[Any]])
}

implicit def UnitTag: Type[Unit] = new TaggedType[Unit]
implicit def BooleanTag: Type[Boolean] = new TaggedType[Boolean]
implicit def ByteTag: Type[Byte] = new TaggedType[Byte]
implicit def CharTag: Type[Char] = new TaggedType[Char]
implicit def ShortTag: Type[Short] = new TaggedType[Short]
implicit def IntTag: Type[Int] = new TaggedType[Int]
implicit def LongTag: Type[Long] = new TaggedType[Long]
implicit def FloatTag: Type[Float] = new TaggedType[Float]
implicit def DoubleTag: Type[Double] = new TaggedType[Double]
implied UnitTag for Type[Unit] = new TaggedType[Unit]
implied BooleanTag for Type[Boolean] = new TaggedType[Boolean]
implied ByteTag for Type[Byte] = new TaggedType[Byte]
implied CharTag for Type[Char] = new TaggedType[Char]
implied ShortTag for Type[Short] = new TaggedType[Short]
implied IntTag for Type[Int] = new TaggedType[Int]
implied LongTag for Type[Long] = new TaggedType[Long]
implied FloatTag for Type[Float] = new TaggedType[Float]
implied DoubleTag for Type[Double] = new TaggedType[Double]
}

/** All implementations of Type[T].
Expand Down
16 changes: 6 additions & 10 deletions library/src-3.x/scala/quoted/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,13 @@ package object quoted {
implicit def autoToExpr[T: Liftable](x: T): Expr[T] = x.toExpr
}

implicit class LiftExprOps[T](val x: T) extends AnyVal {
def toExpr(implicit ev: Liftable[T]): Expr[T] = ev.toExpr(x)
}
implicit object ExprOps {
def (x: T) toExpr[T] given Liftable[T]: Expr[T] = the[Liftable[T]].toExpr(x)

implicit class ListOfExprOps[T](val list: List[Expr[T]]) extends AnyVal {
def toExprOfList(implicit ev: Type[T]): Expr[List[T]] = {
def rec(list: List[Expr[T]]): Expr[List[T]] = list match {
case x :: xs => '{ ($x) :: ${rec(xs)} }
case Nil => '{Nil}
}
rec(list)
def (list: List[Expr[T]]) toExprOfList[T] given Type[T]: Expr[List[T]] = list match {
case x :: xs => '{ $x :: ${xs.toExprOfList} }
case Nil => '{ Nil }
}
}

}