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

Make MonadCont instance for ContT polykinded #129

Closed
Icelandjack opened this issue Aug 8, 2022 · 2 comments
Closed

Make MonadCont instance for ContT polykinded #129

Icelandjack opened this issue Aug 8, 2022 · 2 comments

Comments

@Icelandjack
Copy link

type ContT :: k -> (k -> Type) -> Type -> Type

instance MonadCont (ContT @Type r m)

The MonadCont instance for ContT is unnecessarily restricted to types when it can be polykinded

instance MonadCont (ContT @k r m) where
  callCC :: ((a -> ContT r m b) -> ContT r m a) -> ContT r m a
  callCC cont = ContT \c -> runContT (cont \x -> ContT \ _ -> c x) c

This allows deriving

type Term :: S -> (S -> Type) -> Type

type    ContTerm :: S -> Type -> Type
newtype ContTerm s a = ContTerm ((a -> Term s r) -> Term s r)
  deriving (Functor, Applicative, Monad, MonadCont)
  via ContT @S r (Term s)

The kind of ContT should also be made specifiable: forall k. k -> (k -> Type) -> Type -> Type rather than inferrable forall {k}. .. as it is now.

@kozross
Copy link
Collaborator

kozross commented Aug 8, 2022

I don't object to making MonadCont have more polykinded instances.

@Qqwy
Copy link

Qqwy commented Aug 10, 2022

This seems like a good idea.

Are there any downsides to making this change? I cannot think of any obvious ones at least.

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

3 participants