From ad057986df1ce9482dc2aa3ced6db6be072893e5 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Sun, 12 Dec 2010 21:19:13 -0500 Subject: [PATCH] transformers tweak Signed-off-by: Jim Pryor --- monad_transformers.mdwn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monad_transformers.mdwn b/monad_transformers.mdwn index 57affe59..9f26d615 100644 --- a/monad_transformers.mdwn +++ b/monad_transformers.mdwn @@ -135,6 +135,8 @@ Apart from whose interface is outermost, the behavior of a StateT(Maybe) and a M # module SM = S.T(Maybe_monad);; # MS.(run (elevate (S.puts succ) >> zero () >> elevate S.get >>= fun cur -> unit (cur+10) )) 0;; - : int option * S.store = (None, 1) + # MS.(run (elevate (S.puts succ) >> zero () >> elevate (S.put 5) )) 0;; + - : unit option * S.store = (None, 1) Although we have a wrapped `None`, notice that the store (as it was at the point of failure) is still retrievable. @@ -186,7 +188,7 @@ This is fun. Notice the difference it makes whether the second `plus` is native # LL.(run(plus (unit 1) (unit 2) >>= fun i -> plus (unit i) (unit(10*i)) ));; - : ('_a, int) LL.result = \[[1; 10; 2; 20]] # LL.(run(plus (unit 1) (unit 2) >>= fun i -> elevate L.(plus (unit i) (unit(10*i)) )));; - - : ('_a, int) LL.result = \[[1; 2]; [1; 20]; [10; 2]; [10; 20]] + - : ('_a, int) LL.result = [[1; 2]; [1; 20]; [10; 2]; [10; 20]] -- 2.11.0