
Hi, I am confused by section 4.6 in Yet Another Haskell Tutorial written by Hal Daume III. The auther provides a CPS form of "fold" funtion, but I don't know: 1. How to transform a normal function into CPS function. I need some hint in writting "cfold". 2. Why "cfold" is CPS form? In my mind, if a CPS funtion calls to other CPS function, it must only feed that function with either direct variables or continuations. But in the tutorial, cfold defines: cfold f z l = cfold' (\x t g -> f x (g t)) z l Note that the lambda function body is f x (g t); which means call g(t) first, and take the result, then call f(x, r). It is illegal in CPS because g(t) will never return. This is not same with function f. Here, f can be treated as atomic operation (belong the CPS system). Anyone can help me? Thank you in advance. --- melon