Closed Atry closed 4 years ago
This is interesting, but I'm not sure if it's at all warranted. Especially considering that it will cause breakage. I'm leaning toward a no on this.
Could you explain the motivation and context?
Either way thanks for sharing. But some exposition About context and such would be appreciated
On Sat, Jan 18, 2020 at 11:47 AM chessai notifications@github.com wrote:
This is interesting, but I'm not sure if it's at all warranted. Especially considering that it will cause breakage. I'm leaning toward a no on this.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/haskell/mtl/pull/70?email_source=notifications&email_token=AAABBQVSW2XSTLTXMDBGFMDQ6MXDJA5CNFSM4KISG4P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJJ4UPA#issuecomment-575916604, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAABBQTDR4K6WMA3TYZFJZ3Q6MXDJANCNFSM4KISG4PQ .
The problem is that the existing instance MonadState s m => MonadState s (ContT r m)
conflicts with reader based instance.
Could you elaborate?
@cartazio
A ReaderT
has a simpler implementation than StateT
. Suppose we have the following type:
type X = ContT Text (ReaderT String (ReaderT Double)
With the help of this PR, X
will support both MonadReader String X
and MonadState String X
. Moreover, with the help of https://github.com/haskell/mtl/pull/73, we can even have both MonadReader Double X
and MonadState Double X
. Therefore, monad transformers can be easily extended, used as a simple and fast alternative to Freer
/ Eff
things.
The trick to implement MonadState
from MonadReader
is explored by @ekmett 9 years ago, this PR just applies the same idea to ConT
This would be a weird and confusing departure from the typical lifting witnessed by monad transformers. That is, MTL instances typically lift like:
instance C x m => C x (t m)
and not
instance C0 x m => C1 x (t m)
While clever and certainly used by Codensity, this would cause a lot of breakage and confusion. I'm a strong -1 on this. Feel free to re-open if you want to make a case for this being changed.
agreed
The implementation is inspired by https://github.com/ekmett/kan-extensions/blob/f9f8717883d250c2067c13b1e867274c29d7095e/src/Control/Monad/Codensity.hs#L251