I was using Codensity for some experiments, where it can nicely capture the current continuation. So I was thinking:
Could there be a meaningful MonadCodensity type-class?
One option would be to define it with
reset :: Monad m => Codensity m a -> Codensity m a
shift :: Applicative m => (forall b. (a -> m b) -> Codensity m b) -> Codensity m a
But the problem I see is that m would have to be somehow bound to the type class. Something like
class ... => MonadCodensity c m | m -> c where
reset :: c a -> c a
shift :: (forall b. (a -> m b) -> c b) -> c a
Which leads to the question, if such a type-class would ever be useful, since such a stack could still only allow m b in shift, regardless of other monads in a stack. And therefore, if perhaps Codensity is in essence a "terminal" monad in the sense that it is practical to have it always the last in a monad stack.
I was using
Codensityfor some experiments, where it can nicely capture the current continuation. So I was thinking:Could there be a meaningful
MonadCodensitytype-class?One option would be to define it with
But the problem I see is that
mwould have to be somehow bound to the type class. Something likeWhich leads to the question, if such a type-class would ever be useful, since such a stack could still only allow
m binshift, regardless of other monads in a stack. And therefore, if perhapsCodensityis in essence a "terminal" monad in the sense that it is practical to have it always the last in a monad stack.