Skip to content

Instantly share code, notes, and snippets.

@jjant
Created June 14, 2018 20:16
Show Gist options
  • Save jjant/8a4bd445cff29fde6fd19221c8c385df to your computer and use it in GitHub Desktop.
Save jjant/8a4bd445cff29fde6fd19221c8c385df to your computer and use it in GitHub Desktop.
k0Plusk15 = \k -> k 0 + k 15
myCont = Cont k0Plusk15 -- Extracted the function for ease of notation later below.
myCont2 = myCont >>= (\x -> return (x * 2))
= (Cont k0Plusk15) >>= (\x -> Cont ($ (x * 2)))
= Cont $ \k' -> k0Plusk15 (\x -> runCont (Cont ($ (x * 2))) k')
= Cont $ \k' -> k0Plusk15 (\x -> ($ (x * 2)) k')
= Cont $ \k' -> k0Plusk15 (\x -> k' (x * 2))
= Cont $ \k' -> k0Plusk15 (\x -> k' (x * 2))
= Cont $ \k' -> (\k -> k 0 + k 15) (\x -> k' (x * 2))
= Cont $ \k' -> (\x -> k' (x * 2)) 0 + (\x -> k' (x * 2)) 15
= Cont $ \k' -> k' (0 * 2) + k' (15 * 2)
= Cont $ \k' -> k' 0 + k' 30 -- Ah-ha!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment