I have the following method:
private def optimizeExpr1(body: Expr[Array[Double] => Double])(using QuoteContext): Expr[Double] = body match {
case '{ ($f:((Map[String, Double]) => Array[Double] => Double))($p) } =>
p match {
case '{$m:Map[String, Double]} =>
val map = m.unseal.underlying.seal.cast[Map[String, Double]]
val mapx = '{${map}.toList}
case _ =>
???
}
???
case _ => ???
}
I can successfully match the Map
and get for example:
scala.Predef.Map.apply[java.lang.String, scala.Double](scala.Predef.ArrowAssoc[java.lang.String]("x").->[scala.Double](20.1)) (Apply(TypeApply(Select(Ident("Map"), "apply"), List(Inferred(), Inferred())), List(Typed(Repeated(List(Apply(TypeApply(Select(Apply(TypeApply(Ident("ArrowAssoc"), List(Inferred())), List(Literal(Constant("x")))), "->"), List(Inferred())), List(Literal(Constant(20.1d))))), Inferred()), Inferred()))))
Now how do I “unlift” the map? If I do this directly I get:
[error] 317 | val mapx = map.unliftOrError
[error] | ^
[error] |no implicit argument of type quoted.Unliftable[U] was found for parameter unlift of method unliftOrError in class Expr
TIA