X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;f=state_monad_tutorial.mdwn;fp=state_monad_tutorial.mdwn;h=65020143dd370ca10e319f4d7bc51858e50ab9b6;hb=73b2ed9e0827afa8bd3e993592c72d98b81afe86;hp=bac9124e828bfd6a571ffe0fd8c48591510afa53;hpb=d663eae3baea394ba9d75c24fc05ebb091b87c17;p=lambda.git diff --git a/state_monad_tutorial.mdwn b/state_monad_tutorial.mdwn index bac9124e..65020143 100644 --- a/state_monad_tutorial.mdwn +++ b/state_monad_tutorial.mdwn @@ -100,8 +100,8 @@ Here is how you'd have to do it using our OCaml monad library: # let increment_store'' : ('x,'a) S.m = S.(get >>= fun cur -> let value = cur.total - in let s = { total = succ cur.total; modifications = succ cur.modifications } - in put s >> unit value);; + in let s' = { total = succ cur.total; modifications = succ cur.modifications } + in put s' >> unit value);; Let's try it out: @@ -170,7 +170,7 @@ What are the special-purpose operations that the `State_monad` module defines fo ... >> put new_store >> fun () -> ... - As that code snippets suggests, the boxed value after the application of `puts new_store` is just `()`. If you want to preserve the existing boxed value but replace the store, do this: + As that code snippet suggests, the boxed value after the application of `puts new_store` is just `()`. If you want to preserve the existing boxed value but replace the store, do this: ... >>= fun value -> put new_store >> unit value >>= ...