FT parameter of ErasedProductInstancesN[K, FT] prevents derivation of instances of non-total type families #227
Replies: 4 comments
-
It looks like those type parameters are not used. But I'm also not sure if it would be binary compatible to remove them. |
Beta Was this translation helpful? Give feedback.
-
It's a phantom type argument used to distinguish the instances for different fully applied types. I'm fairly sure it's only used for implicit resolution, and I'm fairly sure it can't simply be removed (which isn't to say we couldn't make some sort of change to accommodate this case). |
Beta Was this translation helpful? Give feedback.
-
Hmm, I see, a regular type alias is used here, allowing type ProductInstances[F[_[_[_]]], T[_[_]]] = ErasedProductInstances[K11.type, F[T]] Perhaps it would be possible to use |
Beta Was this translation helpful? Give feedback.
-
It's not really "escaping" per se. The type alias really is just an abbreviation here: the underlying type has to show through to drive implicit resolution. Switching to an opaque type would break things. |
Beta Was this translation helpful? Give feedback.
-
Take a look at this snippet that I've been playing around with:
To give some background info: The motivation here is to eventually check if for
case class FooHK[F[_]](a: F[Int], b: F[String])
we have thatFooHK[F1] <: FooHK[F2]
. This is the case precisely when for every field typeA
ofFoo
we haveF1[A] <: F2[A]
. DespiteF1
andF2
being functionally identical, summoning an instance ofK0.ProductInstances
fails:Why is that? The problem here is that
F1
andF2
are not total. Their domain covers all the types that appear inFoo
fields, so applying them toFooHK
is legal, however in Shapeless kinds.scala we have this line:That applies
F[T]
, i.e.F1[Foo]
in our example, a case that is not defined and thus fails to reduce.Can we get rid of the
FT
type parameter inErasedProductInstancesN
? What is it needed for?Beta Was this translation helpful? Give feedback.
All reactions