From 3d98e6d16929dbdeb122713b86171b86039dca4a Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Thu, 2 Dec 2010 10:49:20 -0500 Subject: [PATCH] manip trees tweaks Signed-off-by: Jim Pryor --- manipulating_trees_with_monads.mdwn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/manipulating_trees_with_monads.mdwn b/manipulating_trees_with_monads.mdwn index 16097633..10c95564 100644 --- a/manipulating_trees_with_monads.mdwn +++ b/manipulating_trees_with_monads.mdwn @@ -498,7 +498,7 @@ Okay, now let's do the same thing for our Tree monad. let rec bind (u : 'a tree) (f : 'a -> 'b tree) : 'b tree = match u with - | Leaf a -> f a + | Leaf a -> (fun b -> Leaf b) (f a) | Node (l, r) -> (fun l' r' -> Node (l', r')) (bind l f) (bind r f);; (* monadic operations for the TreeT monadic transformer *) @@ -511,7 +511,7 @@ Okay, now let's do the same thing for our Tree monad. let rec bind (u : ('a, M) tree) (f : 'a -> ('b, M) tree) : ('b, M) tree = match u with - | Leaf a -> M.unit (f a) + | Leaf a -> M.bind (f a) (fun b -> M.unit (Leaf b)) | Node (l, r) -> M.bind (bind l f) (fun l' -> M.bind (bind r f) (fun r' -> M.unit (Node (l', r'));; -- 2.11.0