rename some stuff
authorJim Pryor <profjim@jimpryor.net>
Mon, 13 Dec 2010 01:19:25 +0000 (20:19 -0500)
committerJim Pryor <profjim@jimpryor.net>
Mon, 13 Dec 2010 01:19:25 +0000 (20:19 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
code/tree_monadize.ml
manipulating_trees_with_monads.mdwn

index bbd9504..b8b314a 100644 (file)
@@ -184,23 +184,23 @@ module TreeCont =  Tree_monadizer2(Continuation_monad);;
  *)
 
 
-let int_getter : int -> int Reader_monad.monad =
+let asker : int -> int Reader_monad.monad =
   fun (a : int) -> fun (env : int -> int) -> env a;;
 
-(* int_getter takes an int and returns a Reader monad that
+(* asker takes an int and returns a Reader monad that
  * "looks up" that int in the environment (i.e. modifies it)
  * this is structurally parallel to the function `lookup` we used
  * before to "look up" variables in the environment *)
 
 (* double each leaf *)
 let env = fun i -> i + i in
-TreeReader.monadize t1 int_getter env;;
+TreeReader.monadize t1 asker env;;
 
 (* You can also avoid declaring a separate toplevel TreeReader module
  * (or even a separate Reader_monad module) by using one of these forms:
  *     ...
  *     let module T = Tree_monadizer(Reader_monad) in
- *     T.monadize t1 int_getter env;;
+ *     T.monadize t1 asker env;;
  * or:
  *     ...
  *     let env = fun i -> i + i in
@@ -212,7 +212,7 @@ TreeReader.monadize t1 int_getter env;;
  *         fun e -> f (u e) e;;
  *     end in
  *     let module T = Tree_monadizer(Monad) in
- *     T.monadize t1 int_getter env;;
+ *     T.monadize t1 asker env;;
  * or:
  *     ...
  *     let module T = Tree_monadizer(struct
@@ -222,13 +222,13 @@ TreeReader.monadize t1 int_getter env;;
  *       let bind (u : 'a m) (f : 'a -> 'b m) : 'b m =
  *         fun e -> f (u e) e;;
  *     end) in
- *     T.monadize t1 int_getter env;;
+ *     T.monadize t1 asker env;;
  *)
 
 
 (* square each leaf *)
 let env = fun i -> i * i in
-TreeReader.monadize t1 int_getter env;;
+TreeReader.monadize t1 asker env;;
 
 
 
index 59d4458..6677479 100644 (file)
@@ -133,8 +133,8 @@ of that function.
 
 It would be a simple matter to turn an *integer* into an `int reader`:
 
-       let int_getter : int -> int reader = fun (a : int) -> fun (modifier : int -> int) -> modifier a;;
-       int_getter 2 (fun i -> i + i);;
+       let asker : int -> int reader = fun (a : int) -> fun (modifier : int -> int) -> modifier a;;
+       asker 2 (fun i -> i + i);;
        - : int = 4
 
 But how do we do the analagous transformation when our `int`s are scattered over the leaves of a tree? How do we turn an `int tree` into a reader?
@@ -185,17 +185,17 @@ Then we can expect that supplying it to our `int tree reader` will double all th
 In more fanciful terms, the `tree_monadize` function builds plumbing that connects all of the leaves of a tree into one connected monadic network; it threads the
 `'b reader` monad through the original tree's leaves.
 
-       # tree_monadize t1 int_getter double;;
+       # tree_monadize t1 asker double;;
        - : int tree =
        Node (Node (Leaf 4, Leaf 6), Node (Leaf 10, Node (Leaf 14, Leaf 22)))
 
 Here, our environment is the doubling function (`fun i -> i + i`).  If
 we apply the very same `int tree reader` (namely, `tree_monadize
-t1 int_getter`) to a different `int -> int` function---say, the
+t1 asker`) to a different `int -> int` function---say, the
 squaring function, `fun i -> i * i`---we get an entirely different
 result:
 
-       # tree_monadize t1 int_getter square;;
+       # tree_monadize t1 asker square;;
        - : int tree =
        Node (Node (Leaf 4, Leaf 9), Node (Leaf 25, Node (Leaf 49, Leaf 121)))