Skip to content

Type class for MonadCodensity? #81

@ppetr

Description

@ppetr

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions