Created
July 30, 2012 15:07
-
-
Save delbertooo/3207644 to your computer and use it in GitHub Desktop.
Cont Implementierung
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
callCC :: ((a -> Cont r b) -> Cont r a) -> Cont r a | |
callCC f = Cont $ \k -> runCont (f (\a -> Cont $ \_ -> k a)) k |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
instance Monad (Cont r) where | |
return n = Cont (\k -> k n) | |
m >>= f = Cont (\k -> runCont m (\a -> runCont (f a) k)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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