assignment7 tweaks
[lambda.git] / hints / assignment_7_hint_2.mdwn
index 3d08c13..6047aeb 100644 (file)
@@ -5,11 +5,14 @@
 
        However, since we haven't studied these, we will just combine the reader monad and the state monad in an ad hoc way. The easiest way to do this is to think of the assignment function and the store of reference cells as a combined state, which gets threaded through the computations in the same way that simple states did in your earlier homeworks.
 
-       We'll call these "discourse possibility monads," and let them have the following type:
+       We'll call these "discourse possibility monads," and type them as follows:
 
                type entity = Bob | Carol | Ted | Alice;;
+               let domain = [Bob; Carol; Ted; Alice];;
+               type var = char;;
+               type assignment = var -> int;; (* variables are bound to indexes into the store *)
                type store = entity list;;
-               type assignment = char -> int;; (* variables are bound to indexes into the store *)
+
                type 'a discourse_possibility = 
                        (* we ignore worlds *)
                        assignment * store -> 'a * assignment * store
                let bind_set (u: 'a set) (f: 'a -> 'b set) =
                        List.concat (List.map f u);;
 
-*      So GS&V's information states, which they notate using `s`, are set-monads, whose elements in turn are discourse possibilities, which they notate using `i`, which are state monads that keep track of which entities have been introduced as objects of discourse, and which variables are bound to them, in the discourse possibility in question. In GS&V's system, possibilities are triples of an assignment function, `r`, a store `g`, and a world `w`. We're leaving the worlds out. Also, instead of just working with pairs `(r, g)`, we're working with state monads for which those pairs constitute the states we update.
+       The following will be useful later: persuade yourself that `List.filter (test : 'a -> bool) (u : 'a set) : 'a set` is the same as:
+
+               bind_set u (fun a -> if test a then unit_set a else empty_set)
+
+
+*      So GS&V's information states, which they notate using `s`, are set-monads, whose elements in turn are discourse possibilities, which they notate using `i`, which are state monads that keep track of which entities have been introduced as objects of discourse, and which variables are bound to them, in the discourse possibility in question. In GS&V's system, possibilities are triples of an assignment function, `r`, a store `h`, and a world `w`. We're leaving the worlds out. Also, instead of just working with pairs `(r, h)`, we're working with state monads for which those pairs constitute the states we update.
 
 
 *      [More hints](/hints/assignment_7_hint_3).