garbafe
authorjim <jim@web>
Mon, 6 Apr 2015 21:50:53 +0000 (17:50 -0400)
committerLinux User <ikiwiki@localhost.members.linode.com>
Mon, 6 Apr 2015 21:50:53 +0000 (17:50 -0400)
This reverts commit 8071cf9cb642dd55d1d58f6f7afd85a5ff11b5e3

topics/_week9_state_monad_tutorial.mdwn

index def82ba..e586ae0 100644 (file)
@@ -16,7 +16,7 @@ The most lightweight way encapsulate it would be just to add a data constructor
     (* we assume that the store type has already been declared *)
     type 'a state = State of (store -> ('a * store))
 
-Then a function expecting an `'a store` will look for a value with the structure `State ...` rather than just one with the structure `...`.
+Then a function expecting an `'a state` will look for a value with the structure `State ...` rather than just one with the structure `...`.
 
 To take a `State (s -> (a,s))` and get at the `s -> (a,s)` it wraps, you use the same techniques you use to take an `Some int` and get at the `int` it wraps:
 
@@ -38,7 +38,7 @@ with `run xx`. So you should only apply `run` when you've finished building up a
 
 Of course you can do this:
 
-    let xx = someMonad.(...) in
+    let xx = SomeMonad.(...) in
     let intermediate_result = SomeMonad.run xx 0 in
     let yy = SomeMonad.(xx >>= ...) in
     let final_result = SomeMonad.run yy 0 in
@@ -76,9 +76,9 @@ OK, back to our walk-through of "A State Monad Tutorial". What shall we use for
 
     type store' = { total : int; modifications: int };;
 
-State monads employing this store will then have *three* salient values at any point in the computation: the `total` and `modifications` field in the store, and also the `'a` value that is then wrapped in the monadic box.
+State monads employing this store will then have *three* salient values at any point in the computation: the `total` and `modifications` field in the store, and also the `'a` payload that is currently wrapped in the monadic box.
 
-Here's a monadic box that encodes the operation of incrementing the store's `total` and wrapping the value that was the former `total`:
+Here's a monadic value that encodes the operation of incrementing the store's `total` and wrapping the value that was the former `total`:
 
     let increment_store : store' -> (int * store') = fun s ->
       let value = s.total in
@@ -148,7 +148,7 @@ The store keeps the same type throughout the computation, but the type of the wr
 
 What are the special-purpose operations that the `State_monad` module defines for us?
 
-*    `get` is a monadic value that passes through the existing store unchanged, and also wraps that same store as its boxed value. You use it like this:
+*    `get` is a monadic value that passes through the existing store unchanged, and also wraps that same store as its boxed payload. You use it like this:
 
         ... >>= fun _ -> get >>= fun cur -> ... here we can use cur ...
 
@@ -170,11 +170,11 @@ What are the special-purpose operations that the `State_monad` module defines fo
 
         ... >> put new_store >> fun () -> ...
 
-    As that code snippet suggests, the boxed value after the application of `modify 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 payload after the application of `modify new_store` is just `()`. If you want to preserve the existing payload but replace the store, do this:
 
         ... >>= fun value -> put new_store >> unit value >>= ...
 
-*    Finally, `modify modifier` applies `modifier` to whatever the existing store is, and substitutes that as the new store. As with `put`, the boxed value afterwards is `()`.
+*    Finally, `modify modifier` applies `modifier` to whatever the existing store is, and substitutes that as the new store. As with `put`, the boxed payload afterwards is `()`.
 
     <!--
     Haskell calls this operation `modify`. We've called it `puts` because it seems to fit naturally with the convention of `get` vs `gets`. (See also `ask` vs `asks` in `Reader_monad`, which are also the names used in Haskell.)