X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=hints%2Fassignment_7_hint_3.mdwn;h=cbcc5a0be5b55d3d040694134118bd4dff7ce860;hp=ad6d7ea8dbba3416afe15f6b7bffb0661cbacfae;hb=60fde0202775a36c5b20c370374649d2a90c6af8;hpb=be5eb752358a5067486efb6d515411551025f1e1 diff --git a/hints/assignment_7_hint_3.mdwn b/hints/assignment_7_hint_3.mdwn index ad6d7ea8..cbcc5a0b 100644 --- a/hints/assignment_7_hint_3.mdwn +++ b/hints/assignment_7_hint_3.mdwn @@ -9,8 +9,8 @@ type 'a set = 'a list;; let empty_set : 'a set = [];; - let unit_set (x: 'a) : 'a set = [x];; - let bind_set (u: 'a set) (f: 'a -> 'b set) = + let unit_set (value: 'a) : 'a set = [value];; + let bind_set (u: 'a set) (f: 'a -> 'b set) : 'b set = List.concat (List.map f u);; @@ -27,15 +27,19 @@ > \[[expression]] in possibility `(r, h, w)` - we'll just talk about \[[expression]] and let that be a monadic value, implemented in part by a function that takes `(r, h)` as an argument. + we'll just talk about \[[expression]] and let that be a monadic operation, implemented in part by a function that takes `(r, h)` as an argument. + + In particular, the meaning of sentential clauses will be an operation that we monadically bind to an existing `bool dpm set`. Here is its type: + + type clause = bool dpm -> bool dpm set;; * In def 2.7, GS&V talk about an operation that takes an existing set of discourse possibilities, and *extends* each member in the set by (i) allocating a new location in the store, (ii) putting some entity `d` from the domain in that location, and (iii) assigning variable `x` to that location in the store. It will be useful to have a shorthand way of referring to this operation: - let new_peg_and_assign (var_to_bind : char) (d : entity) = - (* we want to return not a function that we can bind to a bool dpm *) - fun (truth_value : bool) : bool dpm -> - fun ((r, h) : assignment * store) -> + (* we want to return a function that we can bind to a bool dpm *) + let new_peg_and_assign (var_to_bind : char) (d : entity) : bool -> bool dpm = + fun truth_value -> + fun (r, h) -> (* first we calculate an unused index *) let new_index = List.length h (* next we store d at h[new_index], which is at the very end of h *) @@ -45,7 +49,7 @@ It will be useful to have a shorthand way of referring to this operation: in let r' = fun var -> if var = var_to_bind then new_index else r var (* we pass through the same truth_value that we started with *) - in (truth_value, r', h') + in (truth_value, r', h');; * Is that enough? If not, here are some [more hints](/hints/assignment_7_hint_4). But try to get as far as you can on your own.