X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=code%2Ftree_monadize.ml;h=b8b314a65d14b5c1319146be7fafbec1ad3d6d18;hp=43d0d981a66161e2f93b8868a040a4ffabac8bac;hb=06846722f1be7c898c2c2b1c33ac2b35955553b7;hpb=434fc9bef584f51ac5338a39dc4ff5da44b5b435 diff --git a/code/tree_monadize.ml b/code/tree_monadize.ml index 43d0d981..b8b314a6 100644 --- a/code/tree_monadize.ml +++ b/code/tree_monadize.ml @@ -130,7 +130,7 @@ end) = struct end;; -(* Now we supply the Reader monad as a parameter to Tree_monadizer. +(* Now we supply Reader_monad as a parameter to Tree_monadizer. * We'll get back a module TreeReader that contains a single value, * the monadize function specialized to the Reader monad *) module TreeReader = Tree_monadizer(Reader_monad);; @@ -184,23 +184,23 @@ module TreeCont = Tree_monadizer2(Continuation_monad);; *) -let get_int : int -> int Reader_monad.monad = +let asker : int -> int Reader_monad.monad = fun (a : int) -> fun (env : int -> int) -> env a;; -(* get_int 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 get_int 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 get_int env;; + * T.monadize t1 asker env;; * or: * ... * let env = fun i -> i + i in @@ -212,7 +212,7 @@ TreeReader.monadize t1 get_int env;; * fun e -> f (u e) e;; * end in * let module T = Tree_monadizer(Monad) in - * T.monadize t1 get_int env;; + * T.monadize t1 asker env;; * or: * ... * let module T = Tree_monadizer(struct @@ -222,13 +222,13 @@ TreeReader.monadize t1 get_int env;; * let bind (u : 'a m) (f : 'a -> 'b m) : 'b m = * fun e -> f (u e) e;; * end) in - * T.monadize t1 get_int env;; + * T.monadize t1 asker env;; *) (* square each leaf *) let env = fun i -> i * i in -TreeReader.monadize t1 get_int env;; +TreeReader.monadize t1 asker env;;