You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I mentioned on gitter, the reason for this is that the LabelledGeneric for A could either be an HList (for case class), or a Coproduct of HLlists if A is a sealed trait with subclasses. We want genericObjectEncoder to work for both, but implicit resolution will neglect to consider it for a Coproduct, because of the H <: HList constraint. Removing it does the trick.
I agree that the book should be amended, I'm happy to make a PR with a small paragraph, but I'm not too sure who the maintainers for this project are, and if they're accepting pull requests.
The knownDirectSubclasses is unrelated to the code in the example, it appears in random cases whenever you try to derive a LabelledGeneric. I think the problem is only definitely solved by enum in Dotty.
@SystemFw hit the nail on the head -- the <: HList annotation shouldn't be there. I'll incorporate this correction in next time I fold errata into the book.
The implicit function
genericObjectEncoder
does not work with Coproduct as descibed in the book.The current definition is as followed:
To make this work, I have to remove
<: HList
.I do not know why this is the case, but I would love to find out more about it.
Other users reported
knownDirectSubclasses
bug, but I do not see this error message.The text was updated successfully, but these errors were encountered: