X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=state_monad_tutorial.mdwn;h=b15ac297c192d40e5336fd8bc672f975aab63a23;hp=65020143dd370ca10e319f4d7bc51858e50ab9b6;hb=8cf1fe240800a66d644f907fad8d618b014efd7d;hpb=73b2ed9e0827afa8bd3e993592c72d98b81afe86 diff --git a/state_monad_tutorial.mdwn b/state_monad_tutorial.mdwn index 65020143..b15ac297 100644 --- a/state_monad_tutorial.mdwn +++ b/state_monad_tutorial.mdwn @@ -95,7 +95,7 @@ If we wanted to work with one of the encapsulation techniques described above, w Here is how you'd have to do it using our OCaml monad library: - # use "path/to/monads.ml";; + # #use "path/to/monads.ml";; # module S = State_monad(struct type store = store' end);; # let increment_store'' : ('x,'a) S.m = S.(get >>= fun cur -> @@ -134,7 +134,7 @@ or, using pattern-matching on the record (you don't have to specify every field let { total = value; _ } = s0 in (value, { total = s0.total + 2; modifications = s0.modifications + 2};; -But **the point of learning how to do this monadically** is that (1) monads show us how to embed more sophisticated programming techniques, such as imperative state and continuations, into frameworks that don't natively possess them (such as the set-theoretic metalanguage of Groenendijk, Stockhof and Veltman's paper); and (2) monads are delicious. +But **the point of learning how to do this monadically** is that (1) monads show us how to embed more sophisticated programming techniques, such as imperative state and continuations, into frameworks that don't natively possess them (such as the set-theoretic metalanguage of Groenendijk, Stokhof and Veltman's paper); (2) becoming familiar with monads will enable you to see patterns you'd otherwise miss, and implement some seemingly complex computations using the same simple patterns (same-fringe is an example); and finally, of course (3) monads are delicious. Keep in mind that the final result of a bind chain doesn't have to be the same type as the starting value: