From 33f70d05dd59fde970ffae4c958f218911435787 Mon Sep 17 00:00:00 2001
From: Jim Pryor
Date: Sun, 21 Nov 2010 09:53:40 -0500
Subject: [PATCH] week9 tweaks
Signed-off-by: Jim Pryor
---
week9.mdwn | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/week9.mdwn b/week9.mdwn
index 084da460..4e334a03 100644
--- a/week9.mdwn
+++ b/week9.mdwn
@@ -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.
-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:
--
2.11.0