Consider the following macro declaration:
def someMacro[Alg[_[_]]](c: Context)(implicit alg: c.WeakTypeTag[Alg[_]])
Unfortunately it does not compile. The error:
_$2 takes no type parameters, expected: 1
Is there a way to fix it up?
CodePudding user response:
Try WeakTypeTag
for a higher-kinded existential type (in forSome
notation)
def someMacro[Alg[_[_]]](c: Context)(implicit alg: c.WeakTypeTag[Alg[F]] forSome { type F[_] })
Self-type annotation for class with higher kinded type
Searching for implicit inside a reify call (scala macro)
Is there a shorthand for type variable 'm forSome { type m[O] <: UpperBound[O] }` in Scala?