-- type Cont = State -> Ans
-- type Step = Cont -> Cont

-- in this toy example, State = Int and Ans = String, very simple

let
    finish s = "Answer is " @ itos(s) -- finish :Cont
and
    increment c s = c (s+1)           -- increment :Step
and
    double c s = c (2*s)              -- double :Step
and
    factorial c s = if s>=0 then      -- factorial :Step
                       let rec f 0 = 1 ||
                               f n = n*f(n-1)
                       in c (f s)             -- usual action
                    else "factorial error"    -- exceptional case

in increment( double( factorial finish )) 1  -- note order !!!
                                             -- ((1+1)*2)!

--\fB Example of use of continuations. \fP
