X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=monad_transformers.mdwn;h=26fb13ff9fc47e5f0969e0e41d4ce52bbbf03c3d;hp=086a2ffc9e227a7a9c55424a3ebc07e948139ddc;hb=1e70b7849153992272e219477464128c8d97789a;hpb=e948c27044f69962483a6c62a8568b84acd5be85 diff --git a/monad_transformers.mdwn b/monad_transformers.mdwn index 086a2ffc..26fb13ff 100644 --- a/monad_transformers.mdwn +++ b/monad_transformers.mdwn @@ -347,13 +347,11 @@ We can use TreeT(Reader) to modify leaves: # let tree_reader = TR.distribute (fun i -> R.asks (fun e -> e i)) t1;; # TR.run tree_reader (fun i -> i+i);; - (* - : int T.tree option = Some (T.Node (T.Node (T.Leaf 4, T.Leaf 6), T.Node (T.Leaf 10, T.Node (T.Leaf 14, T.Leaf 22)))) - *) Here's a comparison of how distribute works for trees and how it works for lists: @@ -383,14 +381,12 @@ We can use TreeT(State) to count leaves: # let tree_counter = TS.distribute (fun i -> S.(puts succ >> unit i)) t1 in TS.run tree_counter 0;; - (* - : int T.tree option * S.store = (Some (T.Node (T.Node (T.Leaf 2, T.Leaf 3), T.Node (T.Leaf 5, T.Node (T.Leaf 7, T.Leaf 11)))), 5) - *) or to annotate leaves: @@ -454,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: