Port PrivateInstances from meow-mtl?
cb372 opened this issue · 5 comments
I always find it a bit surprising that e.g. evidence of MonadState
does not provide evidence of Monad
.
So if I want to write
def foo[F[_]](...)(implicit F: MonadState[F, MyState]) =
for {
a <- firstThing()
b <- secondThing(a)
} yield b
then I have to add a : Monad
context bound. But that feels redundant - it's a MonadState
, so of course it's a Monad
!
If you're using meow-mtl, this can be fixed by importing com.olegpy.meow.prelude._
, thanks to PrivateInstances.
Is there a good reason not to make that functionality available out of the box in cats-mtl?
They are using shapeless LowPriority
, which implies there might be cases where you would want your Monad[F]
evidence to be different from the val monad: Monad[F]
member of MonadState
, but I can't think of a use case where I would want that. Maybe I'm missing something.
Can we provide this without the shapeless
dependency? We could publish it as a different module, but I'm not sure how useful that is vs. just using meow-mtl
.
Well we could just get rid of the implicit LP: LowPriority
, but I’m sure it must be there for a good reason
What if you need F[_] : MonadState[*[_], S] : MonadError[*[_], E]
?
I thought the whole idea of using scato encoding was for allowing one to have several mtl bounds with the same root typeclass without conflicts.
I think without LowPriority
you would get ambiguities. So I'm not sure how feasible this is unfortunately.