X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?a=blobdiff_plain;f=week9.mdwn;h=7ffe03e63d31a3db996c8d8a21e801f78924a4b2;hb=d663eae3baea394ba9d75c24fc05ebb091b87c17;hp=546b2d2c8f10534c2afa178af9109881ad438bbf;hpb=b2d3c1f63719aba7b6fd71d993783a55d9f11df3;p=lambda.git diff --git a/week9.mdwn b/week9.mdwn index 546b2d2c..7ffe03e6 100644 --- a/week9.mdwn +++ b/week9.mdwn @@ -446,9 +446,9 @@ Here's the implementation of the State monad, together with an implementation of (* alternatively, an env could be implemented as type char -> int *) type 'a reader = env -> 'a;; - let unit_reader (value : 'a) : 'a reader = + let reader_unit (value : 'a) : 'a reader = fun e -> value;; - let bind_reader (u : 'a reader) (f : 'a -> 'b reader) : 'b reader = + let reader_bind (u : 'a reader) (f : 'a -> 'b reader) : 'b reader = fun e -> let a = u e in let u' = f a in u' e;; @@ -458,9 +458,9 @@ Here's the implementation of the State monad, together with an implementation of (* this corresponds to having only a single mutable variable *) type 'a state = store -> ('a, store);; - let unit_state (value : 'a) : 'a state = + let state_unit (value : 'a) : 'a state = fun s -> (value, s);; - let bind_state (u : 'a state) (f : 'a -> 'b state) : 'b state = + let state_bind (u : 'a state) (f : 'a -> 'b state) : 'b state = fun s -> let (a, s') = u s in let u' = f a in u' s';; @@ -503,6 +503,8 @@ To get the whole process started, the complex computation so defined will need t in computation initial_store;; +* See also our [[State Monad Tutorial]]. + ##Aliasing or Passing by reference## @@ -751,7 +753,7 @@ Programming languages tend to provide a bunch of mutation-related capabilities a In point 7 of the Rosetta Stone discussion, the contrast between call-by-name and call-by-value evaluation order appears (though we don't yet call it that). We'll be discussing that more in coming weeks. In the [[damn]] example, continuations and other kinds of side-effects (namely, printing) make an appearance. These too will be center-stage in coming weeks. -* Now would also be a good time to read [[Advanced Topics/Calculator Improvements]]. This reviews the different systems discussed above, as well as other capabilities we can add to the calculators introduced in [week7](/reader_monad_for_variable_binding). We will be building off of that in coming weeks. +* Now would also be a good time to read [Calculator Improvements](/week10). This reviews the different systems discussed above, as well as other capabilities we can add to the calculators introduced in [week7](/reader_monad_for_variable_binding). We will be building off of that in coming weeks. ##Offsite Reading##