Created
June 13, 2018 22:53
-
-
Save jjant/1d20f0c5bc0522c3f0d96d2f6f589bfc to your computer and use it in GitHub Desktop.
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
myCont2 :: Cont Int Int | |
myCont2 = Cont (\k -> k 0 + k 15) | |
plus1 :: Int -> Int | |
plus1 x = x + 1 | |
runCont myCont2 plus1 -- plus1 0 + plus1 15 = 1 + 16 = 17 | |
plus100 :: Int -> Int | |
plus100 x = x + 100 | |
myMappedCont = fmap plus100 myCont2 | |
runCont myCont2 plus1 -- (plus1 . plus100) 0 + (plus1 . plus100) 15 = | |
-- plus1 (plus100 0) + plus1 (plus100 15) = | |
-- plus1 100 + plus1 115 = | |
-- 101 + 116 = 217 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment