Closed keuhdall closed 10 months ago
Hi, it looks like there was an oversight while implementing Show
- we should be using ContravariantShow
.
In the meantime you can work around this problem by defining given [A <: String]: Show[A] = _.toString
.
The fix works indeed, thanks !
Out of curiosity I tried deriving Eq
, and I get the same issue, so it affects probably other typeclasses too.
Out of curiosity I tried deriving Eq, and I get the same issue, so it affects probably other typeclasses too.
True, but there is no ContravariantEq
typeclass. Now that I thought of it some more maybe this should be fixed in Cats proper by adding those instances 🤔 - about Eq
it could even just return true for singleton types.
Sorry for the late reply, should I open an issue on Cats related to this one ?
Sorry for the late reply, should I open an issue on Cats related to this one ?
That would be helpful, yes 👍
Will do ! I took some time to test most of the typeclasses supported by kittens (I used the same case class as above for my tests), here's a recap:
Typeclass | Status |
---|---|
Eq | ❌ |
PartialOrder | ❌ |
Order | ❌ |
Hash | ❌ |
Show | ❌ |
Semigroup | ❌ |
CommutativeSemigroup | ❌ |
Monoid | ❌ |
CommutativeMonoid | ❌ |
Functor | ✅ |
Contravariant | ✅ |
Invariant | ✅ |
Pure * | ❌ |
Apply | ❌ |
Applicative | ❌ |
Foldable | ✅ |
Reducible | ❌ |
Traverse | ✅ |
Empty * | ❌ |
NonEmptyTraverse | ❌ |
Here's my take on it:
Typeclass | Status |
---|---|
Eq | We can probably implement it here |
PartialOrder | We can probably implement it here |
Order | We can probably implement it here |
Hash | Theoretically it should work, but it's tricky |
Show | We can use ContravariantShow |
Semigroup | Can't work - how do you combine singletons? |
CommutativeSemigroup | Same as Semigroup |
Monoid | Same as Semigroup |
CommutativeMonoid | Same as Semigroup |
Functor | ✅ |
Contravariant | ✅ |
Invariant | ✅ |
Pure * | We can probably make it work |
Apply | Can't work because no Semigroup |
Applicative | Can't work because no Semigroup |
Foldable | ✅ |
Reducible | That's surprising, it should work |
Traverse | ✅ |
Empty * | I don't think we should allow this |
NonEmptyTraverse | That's surprising, it should work |
@keuhdall I've implemented my suggestion - lmk what you think
Hi, I've been trying to use kittens to derive
Show
on one of my case class, however it seems to fail because of the type literals.My case class looks like this:
When compiling, I get the following error message:
However, when switching types of
token_type
andscope
back toString
, everything works just fine.I'm using kittens 3.0.0 and Scala 3.3.0