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=96e47410540b85308d99988ab90d3dd81a8df9b4;hb=3ed8e56bf33b1c0cfa09b672abf26e9c397ea0f1;hpb=6da4e7b4835a68593ed7996f7cb4e577aed625c7 diff --git a/hints/assignment_7_hint_2.mdwn b/hints/assignment_7_hint_2.mdwn index 96e47410..9c1079c3 100644 --- a/hints/assignment_7_hint_2.mdwn +++ b/hints/assignment_7_hint_2.mdwn @@ -20,9 +20,9 @@ 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.