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
The Monad constraint on MonadReader is a bit too constraining for me; I'd really like to loosen that constraint to Applicative (or looser?) while breaking the least amount of code possible.
So now that we've made Applicative a superclass of Monad, that would make such a transition considerably easier. However, simply changing Monad to Alternative, while it shouldn't break instances, would break client code that use the Monad class but don't explicitly declare (Monad m, MonadReader m) =>.
It seems fairly safe to assume there's more client code than there are instances, one possibility would be to have something like the following:
class Applicative m => ApplicativeReader r m | m -> r where
ask :: ...
local :: ...
reader :: ...
class (Monad m, ApplicativeReader m) => MonadReader m
instance (Monad m, ApplicativeReader m) => MonadReader m
Then, the only thing people would have to do would be to replace the name MonadReader with ApplicativeReader in all their instances. This might cause some problems for people who don't update their instances and have have OverlappingInstances turned on; it would seem preferable to make MonadReader a closed typeclass or a typeclass synonym.
Making MonadReader a typeclass synonym is possible with ConstraintKinds, but would also require ConstraintKinds to be enabled in all code that mentions the MonadReader constraint.
The text was updated successfully, but these errors were encountered:
I think I place this in the bin of ideas for a major mtl 3 rewrite. The major concern I have is that when you go to state laws for the transformers, many of them cannot be stated for the Applicative-only form.
The
Monad
constraint onMonadReader
is a bit too constraining for me; I'd really like to loosen that constraint toApplicative
(or looser?) while breaking the least amount of code possible.So now that we've made
Applicative
a superclass ofMonad
, that would make such a transition considerably easier. However, simply changingMonad
toAlternative
, while it shouldn't break instances, would break client code that use theMonad
class but don't explicitly declare(Monad m, MonadReader m) =>
.It seems fairly safe to assume there's more client code than there are instances, one possibility would be to have something like the following:
Then, the only thing people would have to do would be to replace the name
MonadReader
withApplicativeReader
in all their instances. This might cause some problems for people who don't update their instances and have haveOverlappingInstances
turned on; it would seem preferable to makeMonadReader
a closed typeclass or a typeclass synonym.Making
MonadReader
a typeclass synonym is possible withConstraintKinds
, but would also requireConstraintKinds
to be enabled in all code that mentions theMonadReader
constraint.The text was updated successfully, but these errors were encountered: