week9 tweaks
authorJim Pryor <profjim@jimpryor.net>
Sun, 21 Nov 2010 14:53:40 +0000 (09:53 -0500)
committerJim Pryor <profjim@jimpryor.net>
Sun, 21 Nov 2010 14:53:40 +0000 (09:53 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
week9.mdwn

index 084da46..4e334a0 100644 (file)
@@ -431,9 +431,9 @@ In this usage, we don't care what value is wrapped by `some_existing_state_monad
 
 We can of course define more complex functions that perform the `get_state >>= (fun cur_state -> set_state (cur_state + 1)` as a single operation.
 
 
 We can of course define more complex functions that perform the `get_state >>= (fun cur_state -> set_state (cur_state + 1)` as a single operation.
 
-In general, a State monadic **value** (type 'a state, what appears at the start of a `... >>= ... >>= ...` chain) is an operation that accepts some starting store as input---where the store might be simple as it is here, or much more complex---and returns a value plus a possibly modified store. This can be thought of as an encoding of some operation on a store serving as a box wrapped around a value.
+In general, a State monadic **value** (type `'a state`, what appears at the start of a `... >>= ... >>= ...` chain) is an operation that accepts some starting store as input---where the store might be simple as it is here, or much more complex---and returns a value plus a possibly modified store. This can be thought of as an encoding of some operation on a store serving as a box wrapped around a value.
 
 
-State monadic **operations** (type 'a -> 'b state, what appears anywhere in the middle or end of a `... >>= ... >>= ...` chain) are operations that generate new State monadic values, based on what value was wrapped by the preceding elements in the `... >>= ... >>= ...` chain. The computations on a store that these encode (which their values may or may not be sensitive to) will be chained in the order given by their position in the `... >>= ... >>= ...` chain. That is, the computation encoded by the first element in the chain will accept a starting store s0 as input, and will return (a value and) a new store s1 as output, the next computation will get s1 as input and will return s2 as output, the next computation will get s2 as input, ... and so on.
+State monadic **operations** (type `'a -> 'b state`, what appears anywhere in the middle or end of a `... >>= ... >>= ...` chain) are operations that generate new State monadic values, based on what value was wrapped by the preceding elements in the `... >>= ... >>= ...` chain. The computations on a store that these encode (which their values may or may not be sensitive to) will be chained in the order given by their position in the `... >>= ... >>= ...` chain. That is, the computation encoded by the first element in the chain will accept a starting store s0 as input, and will return (a value and) a new store s1 as output, the next computation will get s1 as input and will return s2 as output, the next computation will get s2 as input, ... and so on.
 
 To get the whole process started, the complex computation so defined will need to be given a starting store. So we'd need to do something like this:
 
 
 To get the whole process started, the complex computation so defined will need to be given a starting store. So we'd need to do something like this: