Open alexandru opened 1 year ago
Hm good question ... not sure if that's possible. As I understand you'd like to invoke derivation for the leaves here. But how should magnolia know if in a specific case it should use the available implicit, or invoke its own derivation?
Probably not very useful, but I think explicitly specifying the implicits for the leaves might work:
implicit lazy val logShow: LogShow[Robot] = LogShow.derive[Robot]
implicit lazy val logShow: LogShow[User] = LogShow.derive[User]
implicit lazy val logShow: LogShow[Entity] = LogShow.derive[Entity]
though I haven't tested this
Hi all,
I have this typeclass that's contravariant in its type parameter (sorry for any compilation errors, I had to modify the code in-place):
Then I have the following test:
Invoking this
logShow
leads to a stack-overflow error.It makes sense to me because the auto-derivation logic looks for instances of
LogShow[Robot]
orLogShow[User]
, which are hitting the samelazy val
.Are there some tricks I could use here to deal with variance like this?