week9 reference tweak
[lambda.git] / monad_transformers.mdwn
index d387097..26fb13f 100644 (file)
@@ -450,7 +450,7 @@ TreeCont.monadize Continuation_monad.unit t1 initial_continuation;;
           (T.Node (T.Leaf 2, T.Leaf 3),
                T.Node (T.Leaf 5, T.Node (T.Leaf 7, T.Leaf 11))))
 
-We can square each leaf. The meaning of `shift` will be explained in [[CPS and Continuation Operators]].
+We can square each leaf:
 <!--
 let initial_continuation = fun t -> t in
 TreeCont.monadize (fun a k -> k (a*a)) t1 initial_continuation;;
@@ -463,7 +463,13 @@ TreeCont.monadize (fun a k -> k (a*a)) t1 initial_continuation;;
           (T.Node (T.Leaf 4, T.Leaf 9),
                T.Node (T.Leaf 25, T.Node (T.Leaf 49, T.Leaf 121))))
 
-We can count the leaves:
+The meaning of `shift` will be explained in [[CPS and Continuation Operators]]. Here you should just regard it as a primitive operation in our Continuation monad. In [this code](/code/tree_monadize.ml) you could simply write:
+
+       TreeCont.monadize (fun a -> fun k -> k (a*a)) t1 (fun t -> t);;
+
+But because of the way our monad library hides the underlying machinery, here you can no longer just say `fun k -> k (a*a)`; you have to say `shift (fun k -> k (a*a))`.
+
+Moving on, we can count the leaves:
 <!--
 let initial_continuation = fun t -> 0 in
 TreeCont.monadize (fun a k -> 1 + k a) t1 initial_continuation;;
@@ -473,7 +479,7 @@ TreeCont.monadize (fun a k -> 1 + k a) t1 initial_continuation;;
        - : int = 5
 
 
-We can convert the tree to a list of leaves:
+And we can convert the tree to a list of leaves:
 <!--
 let initial_continuation = fun t -> [] in
 TreeCont.monadize (fun a k -> a :: k a) t1 initial_continuation;;