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

MonadCont instance for Codensity #3

Open
fizruk opened this issue Nov 22, 2013 · 0 comments
Open

MonadCont instance for Codensity #3

fizruk opened this issue Nov 22, 2013 · 0 comments

Comments

@fizruk
Copy link

fizruk commented Nov 22, 2013

There exist at least 2 conflicting candidatures:

-- 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))
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