Skip to content

Instantly share code, notes, and snippets.

@delbertooo
Created July 30, 2012 15:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save delbertooo/3207644 to your computer and use it in GitHub Desktop.
Save delbertooo/3207644 to your computer and use it in GitHub Desktop.
Cont Implementierung
callCC :: ((a -> Cont r b) -> Cont r a) -> Cont r a
callCC f = Cont $ \k -> runCont (f (\a -> Cont $ \_ -> k a)) k
instance Monad (Cont r) where
return n = Cont (\k -> k n)
m >>= f = Cont (\k -> runCont m (\a -> runCont (f a) k))
newtype Cont r a = Cont { runCont :: (a -> r) -> r }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment