Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Type class for MonadCodensity? #81

Open
ppetr opened this issue Aug 29, 2024 · 0 comments
Open

Type class for MonadCodensity? #81

ppetr opened this issue Aug 29, 2024 · 0 comments

Comments

@ppetr
Copy link

ppetr commented Aug 29, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant