Make MonadCont instance for ContT polykinded
Icelandjack opened this issue · 2 comments
Icelandjack commented
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 commented
I don't object to making MonadCont
have more polykinded instances.
Qqwy commented
This seems like a good idea.
Are there any downsides to making this change? I cannot think of any obvious ones at least.