Skip to content

Instantly share code, notes, and snippets.

@jjant
Created June 13, 2018 22:53
Show Gist options
  • Save jjant/1d20f0c5bc0522c3f0d96d2f6f589bfc to your computer and use it in GitHub Desktop.
Save jjant/1d20f0c5bc0522c3f0d96d2f6f589bfc to your computer and use it in GitHub Desktop.
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