Home > Mobile >  WeakTypeTag for higher kinded type
WeakTypeTag for higher kinded type

Time:01-18

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?

How to define an existential higher kinded type in Scala

Existential Higher Kinded Method Parameter

  • Related