-- Codensity (Const r) ~ Cont r
instance MonadCont (Codensity (Const r)) where
callCC f = Codensity (\k -> mapConst $ runCodensity (f (\x -> Codensity (\_ -> mapConst $ k x))) k)
where
mapConst :: Const r a -> Const r b
mapConst = Const . runConst
-- using callCC of m
instance MonadCont m => MonadCont (Codensity m) where
callCC f = join . lift $ callCC (\k -> return $ f (lift . k . return))
There exist at least 2 conflicting candidatures: