-
Notifications
You must be signed in to change notification settings - Fork 531
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Implicit inference for ops.record.Selector doesn't work when Id is passed to a HKT #889
Comments
Note that For all I know, this could be a bug in the scala compiler. |
With [info] /home/georgi/work/oss/scratch/src/main/scala/HktId.scala:7:22: shapeless.this.Generic.materialize is not a valid implicit value for shapeless.Generic.Aux[HktId.Hkt[[+T]T],V] because:
[info] hasMatchingSymbol reported error: type mismatch;
[info] found : HktId.Hkt[Any]
[info] required: HktId.Hkt[[+T]T]
[info] Note: Any >: [+T]T, but class Hkt is invariant in type F.
[info] You may wish to define F as -F instead. (SLS 4.5)
[info] func[Hkt[Id]].apply('foo)
[info] ^
[info] /home/georgi/work/oss/scratch/src/main/scala/HktId.scala:7:22: shapeless.this.LabelledGeneric.materializeCoproduct is not a valid implicit value for shapeless.LabelledGeneric[HktId.Hkt[[+T]T]]{type Repr = R} because:
[info] hasMatchingSymbol reported error: could not find implicit value for parameter gen: shapeless.Generic.Aux[HktId.Hkt[[+T]T],V]
[info] func[Hkt[Id]].apply('foo)
[info] ^
[info] /home/georgi/work/oss/scratch/src/main/scala/HktId.scala:7:22: shapeless.this.Generic.materialize is not a valid implicit value for shapeless.Generic.Aux[HktId.Hkt[[+T]T],V] because:
[info] hasMatchingSymbol reported error: type mismatch;
[info] found : HktId.Hkt[Any]
[info] required: HktId.Hkt[[+T]T]
[info] Note: Any >: [+T]T, but class Hkt is invariant in type F.
[info] You may wish to define F as -F instead. (SLS 4.5)
[info] func[Hkt[Id]].apply('foo)
[info] ^
[info] /home/georgi/work/oss/scratch/src/main/scala/HktId.scala:7:22: shapeless.this.LabelledGeneric.materializeProduct is not a valid implicit value for shapeless.LabelledGeneric[HktId.Hkt[[+T]T]]{type Repr = R} because:
[info] hasMatchingSymbol reported error: could not find implicit value for parameter gen: shapeless.Generic.Aux[HktId.Hkt[[+T]T],V]
[info] func[Hkt[Id]].apply('foo)
[info] ^
[error] /home/georgi/work/oss/scratch/src/main/scala/HktId.scala:7:22: could not find implicit value for parameter gen: shapeless.LabelledGeneric[HktId.Hkt[[+T]T]]{type Repr = R}
[error] func[Hkt[Id]].apply('foo)
[error] ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed That |
Ah, ofc, it's because this doesn't work either: val x: Hkt[Id] = Hkt("foo")
[error] found : HktId.Hkt[Any]
[error] required: HktId.Hkt[shapeless.Id]
[error] Note: Any >: shapeless.Id, but class Hkt is invariant in type F.
[error] You may wish to define F as -F instead. (SLS 4.5)
[error] val x: Hkt[Id] = Hkt("foo") Code like this is generated by the |
Does the contravariant workaround |
I wouldn't expect it to work. In this case the error message is not helpful. This is one of the issues with |
Hmm, actually it works in dotty: scala> case class Hkt[F[_]](foo: F[String])
// defined case class Hkt
scala> type Id[+T] = T
// defined alias type Id = [+T] => T
scala> val x: Hkt[Id] = Hkt("foo")
val x: Hkt[Id] = Hkt(foo) So it can be fixed! |
The text was updated successfully, but these errors were encountered: