
On January 17, 2011 19:24:12 Jan-Willem Maessen wrote:
join (CPS f) = CPS $ \k -> unCPS (f id) k
<snip>
Using these definitions, and join = (>>= id), we obtain:
join (CPS cca) = CPS (\k -> cca (\ca -> unCPS ca k))
That is the same. The key is that the final computation here is unCPS ca k. Delaying the application of k (returning unCPS ca and then applying k gives the same result as directly applying unCPS ca k and returning it) we get join (CPS cca) = CPS (\k -> cca (\ca -> unCPS ca k)) join (CPS cca) = CPS (\k -> cca (\ca -> unCPS ca) k) Now, delaying the transformation by unCPS (returning ca and then forming unCPS ca gives the same result as directly forming unCPS ca and returning it) we get join (CPS cca) = CPS (\k -> unCPS (cca (\ca -> ca)) k) join (CPS cca) = CPS (\k -> unCPS (cca id) k) which brings us back to the above. Cheers! -Tyson