-tree`) into a reader object of type `(int->int)-> int tree`: something
-that, when you apply it to an `int->int` function returns an `int
-tree` in which each leaf `x` has been replaced with `(f x)`.
-
-With previous readers, we always knew which kind of environment to
-expect: either an assignment function (the original calculator
-simulation), a world (the intensionality monad), an integer (the
-Jacobson-inspired link monad), etc. In this situation, it will be
-enough for now to expect that our reader will expect a function of
-type `int->int`.
-
-<pre>
-type 'a reader = (int->int) -> 'a;; (* mnemonic: e for environment *)
-let reader_unit (x:'a): 'a reader = fun _ -> x;;
-let reader_bind (u: 'a reader) (f:'a -> 'c reader):'c reader = fun e -> f (u e) e;;
-</pre>
-
-It's easy to figure out how to turn an `int` into an `int reader`:
-
-<pre>
-let int2int_reader (x:'a): 'b reader = fun (op:'a -> 'b) -> op x;;
-int2int_reader 2 (fun i -> i + i);;
-- : int = 4
-</pre>
-
-But what do we do when the integers are scattered over the leaves of a
-tree? A binary tree is not the kind of thing that we can apply a
-function of type `int->int` to.
-
-<pre>
-let rec treemonadizer (f:'a -> 'b reader) (t:'a tree):('b tree) reader =
- match t with Leaf x -> reader_bind (f x) (fun x' -> reader_unit (Leaf x'))
- | Node (l, r) -> reader_bind (treemonadizer f l) (fun x ->
- reader_bind (treemonadizer f r) (fun y ->
- reader_unit (Node (x, y))));;
-</pre>
+tree`) into a reader monadic object of type `(int -> int) -> int
+tree`: something that, when you apply it to an `int -> int` function
+`f` returns an `int tree` in which each leaf `i` has been replaced
+with `f i`.
+
+[Application note: this kind of reader object could provide a model
+for Kaplan's characters. It turns an ordinary tree into one that
+expects contextual information (here, the `λ f`) that can be
+used to compute the content of indexicals embedded arbitrarily deeply
+in the tree.]
+
+With our previous applications of the Reader monad, we always knew
+which kind of environment to expect: either an assignment function, as
+in the original calculator simulation; a world, as in the
+intensionality monad; an individual, as in the Jacobson-inspired link
+monad; etc. In the present case, we expect that our "environment"
+will be some function of type `int -> int`. "Looking up" some `int` in
+the environment will return us the `int` that comes out the other side
+of that function.
+
+ type 'a reader = (int -> int) -> 'a;; (* mnemonic: e for environment *)
+ let reader_unit (a : 'a) : 'a reader = fun _ -> a;;
+ let reader_bind (u: 'a reader) (f : 'a -> 'b reader) : 'b reader = fun e -> f (u e) e;;
+
+It would be a simple matter to turn an *integer* into an `int reader`:
+
+ let int_readerize : int -> int reader = fun (a : int) -> fun (modifier : int -> int) -> modifier a;;
+ int_readerize 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?
+A tree is not the kind of thing that we can apply a
+function of type `int -> int` to.
+
+But we can do this:
+
+ let rec tree_monadize (f : 'a -> 'b reader) (t : 'a tree) : 'b tree reader =
+ match t with
+ | Leaf a -> reader_bind (f a) (fun b -> reader_unit (Leaf b))
+ | Node (l, r) -> reader_bind (tree_monadize f l) (fun l' ->
+ reader_bind (tree_monadize f r) (fun r' ->
+ reader_unit (Node (l', r'))));;