Internal unsafe API representing a poly-kinded, higher-kinded type tag.
Internal unsafe API representing a poly-kinded, higher-kinded type tag.
To create a Tag* implicit for an arbitrary kind use the following syntax:
type TagK5[K[_, _, _, _, _]] = HKTag[ { type Arg[A, B, C, D, E] = K[A, B, C, D, E] } ]
As an argument to HKTag, you should specify the type variables your type parameter will take and apply them to it, in order.
type TagFGC[K[_[_, _], _[_], _[_[_], _, _, _]] = HKTag[ { type Arg[A[_, _], B[_], C[_[_], _, _, _]] = K[A, B, C] } ]
A convenience macro Tag.auto.T
is available to automatically create a type lambda for a type of any kind:
def x[K[_[_, _], _[_], _[_[_], _, _, _]: Tag.auto.T]: Tag.auto.T[K] = implicitly[Tag.auto.T[K]]
Force eager expansion for all recursive implicit searches inside TagMacro by introducing a proxy implicit to display better error messages
Force eager expansion for all recursive implicit searches inside TagMacro by introducing a proxy implicit to display better error messages
test ResourceEffectBindingsTest."Display tag macro stack trace when ResourceTag is not found"
Like scala.reflect.api.TypeTags.TypeTag, but supports higher-kinded type tags via TagK
type class.
Like scala.reflect.api.TypeTags.TypeTag, but supports higher-kinded type tags via TagK
type class.
In context of DI this lets you define modules parameterized by higher-kinded type parameters.
This is especially helpful for applying tagless final
style
Example:
class MyModule[F[_]: Monad: TagK] { make[MyService[F]] make[F[Int]].named("lucky-number").from(Monad[F].pure(7)) }
Without a TagK
constraint above, this example would fail with no TypeTag available for MyService[F]
error
Currently some limitations apply as to when a Tag
will be correctly constructed:
* Type Parameters do not yet resolve inside structural refinements, e.g. T in
Tag[{ def x: T}]
* TagK* does not resolve for constructors with bounded parameters, e.g. S in
class Abc[S <: String]; TagK[Abc]
(You can still have a bound in partial application: e.g.
class Abc[S <: String, A]; TagK[Abc["hi", ?]]
* Further details at https://github.com/7mind/izumi/issues/374
"Lightweight Scala Reflection and why Dotty needs TypeTags reimplemented" https://blog.7mind.io/lightweight-reflection.html
TagK
is like a scala.reflect.api.TypeTags.TypeTag but for higher-kinded types.
TagK
is like a scala.reflect.api.TypeTags.TypeTag but for higher-kinded types.
Example:
def containerTypesEqual[F[_]: TagK, K[_]: TagK]): Boolean = TagK[F].tag.tpe =:= TagK[K].tag.tpe containerTypesEqual[Set, collection.immutable.Set] == true containerTypesEqual[Array, List] == false