X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=hints%2Fassignment_7_hint_2.mdwn;h=9c1079c3858e0ad4ba53b24fcf85ae08d58efb24;hp=17a3955ad5366789ff6f741f5841f5096baca092;hb=9c7ca26e6dd0c1ce1b6cd653e27a083b7379a5dd;hpb=5ffb50f1092baa2b76c7140b8c388d241240fa38 diff --git a/hints/assignment_7_hint_2.mdwn b/hints/assignment_7_hint_2.mdwn index 17a3955a..9c1079c3 100644 --- a/hints/assignment_7_hint_2.mdwn +++ b/hints/assignment_7_hint_2.mdwn @@ -16,13 +16,13 @@ (* we ignore worlds *) assignment * store -> 'a * assignment * store - Although we're leaving worlds out of the picture, each of these monadic values still represents a different discourse possibility: which entities might be being talked about, using which variables. + Although we're leaving worlds out of the picture, each of these monadic values still represents a different *discourse* possibility: which entities might be being talked about, using which variables. Since `dpm`s are to be a monad, we have to define a unit and a bind. These are just modeled on the unit and bind for the state monad: - let unit_dpm (x : 'a) = fun (r, h) -> (x, r, h);; + let unit_dpm (value : 'a) : 'a dpm = fun (r, h) -> (value, r, h);; - let bind_dpm (u : 'a dpm) (f : 'a -> 'b dpm) = + let bind_dpm (u : 'a dpm) (f : 'a -> 'b dpm) : 'b dpm = fun (r, h) -> let (a, r', h') = u (r, h) in let u' = f a @@ -30,5 +30,5 @@ * A *possibility* for GS&V is a triple of an assignment function `r`, a store `h`, and a world `w`. We're dropping worlds so we'll call pairs `(r, h)` *discourse possibilities*. *dpm*s are monads that represent computations that may mutate---or in GS&V's terminology "extend"---discourse possibilities. An `'a dpm` is a function that takes a starting `(r, h)` and returns an `'a` and a possibly mutated `r'` and `h'`. -* Is that enough? If not, here are some [more hints](/hints/assignment_7_hint_3). +* Is that enough? If not, here are some [more hints](/hints/assignment_7_hint_3). But try to get as far as you can on your own.