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
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] or LogShow[User], which are hitting the same lazy val.
Are there some tricks I could use here to deal with variance like this?
The text was updated successfully, but these errors were encountered:
alexandru
changed the title
StackOverflowException on deriving instances for contra-variant type-class
StackOverflowException for contra-variant type-class
Apr 10, 2023
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:
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?
The text was updated successfully, but these errors were encountered: