From 47b863bd1121e6f1617da773dc36253b8f6f4215 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Mon, 13 Dec 2010 08:34:37 -0500 Subject: [PATCH 1/1] delete tests from code Signed-off-by: Jim Pryor --- code/monads.ml | 119 --------------------------------------------------------- 1 file changed, 119 deletions(-) diff --git a/code/monads.ml b/code/monads.ml index be375329..3fba1f32 100644 --- a/code/monads.ml +++ b/code/monads.ml @@ -949,42 +949,6 @@ end * >>= fun x -> unit (x, 0) * in run u) * - * - * (* (+ 1000 (prompt (+ 100 (shift k (+ 10 1))))) ~~> 1011 *) - * let example1 () : int = - * Continuation_monad.(let v = reset ( - * let u = shift (fun k -> unit (10 + 1)) - * in u >>= fun x -> unit (100 + x) - * ) in let w = v >>= fun x -> unit (1000 + x) - * in run w) - * - * (* (+ 1000 (prompt (+ 100 (shift k (k (+ 10 1)))))) ~~> 1111 *) - * let example2 () = - * Continuation_monad.(let v = reset ( - * let u = shift (fun k -> k (10 :: [1])) - * in u >>= fun x -> unit (100 :: x) - * ) in let w = v >>= fun x -> unit (1000 :: x) - * in run w) - * - * (* (+ 1000 (prompt (+ 100 (shift k (+ 10 (k 1)))))) ~~> 1111 but added differently *) - * let example3 () = - * Continuation_monad.(let v = reset ( - * let u = shift (fun k -> k [1] >>= fun x -> unit (10 :: x)) - * in u >>= fun x -> unit (100 :: x) - * ) in let w = v >>= fun x -> unit (1000 :: x) - * in run w) - * - * (* (+ 100 ((prompt (+ 10 (shift k k))) 1)) ~~> 111 *) - * (* not sure if this example can be typed without a sum-type *) - * - * (* (+ 100 (prompt (+ 10 (shift k (k (k 1)))))) ~~> 121 *) - * let example5 () : int = - * Continuation_monad.(let v = reset ( - * let u = shift (fun k -> k 1 >>= fun x -> k x) - * in u >>= fun x -> unit (10 + x) - * ) in let w = v >>= fun x -> unit (100 + x) - * in run w) - * *) @@ -1066,86 +1030,3 @@ end = struct end;; - -module C = Continuation_monad;; - - -print_endline "=== test TreeT(Continuation).distribute ==================";; - -let id : 'z. 'z -> 'z = fun x -> x - -let example n : (int * int) = - Continuation_monad.(let u = callcc (fun k -> - (if n < 0 then k 0 else unit [n + 100]) - (* all of the following is skipped by k 0; the end type int is k's input type *) - >>= fun [x] -> unit (x + 1) - ) - (* k 0 starts again here, outside the callcc (...); the end type int * int is k's output type *) - >>= fun x -> unit (x, 0) - in run0 u) - - -(* (+ 1000 (prompt (+ 100 (shift k (+ 10 1))))) ~~> 1011 *) -let example1 () : int = - Continuation_monad.(let v = reset ( - let u = shift (fun k -> unit (10 + 1)) - in u >>= fun x -> unit (100 + x) - ) in let w = v >>= fun x -> unit (1000 + x) - in run0 w) - -(* (+ 1000 (prompt (+ 100 (shift k (k (+ 10 1)))))) ~~> 1111 *) -let example2 () = - Continuation_monad.(let v = reset ( - let u = shift (fun k -> k (10 :: [1])) - in u >>= fun x -> unit (100 :: x) - ) in let w = v >>= fun x -> unit (1000 :: x) - in run0 w) - -(* (+ 1000 (prompt (+ 100 (shift k (+ 10 (k 1)))))) ~~> 1111 but added differently *) -let example3 () = - Continuation_monad.(let v = reset ( - let u = shift (fun k -> k [1] >>= fun x -> unit (10 :: x)) - in u >>= fun x -> unit (100 :: x) - ) in let w = v >>= fun x -> unit (1000 :: x) - in run0 w) - -(* (+ 100 ((prompt (+ 10 (shift k k))) 1)) ~~> 111 *) -(* not sure if this example can be typed without a sum-type *) - -(* (+ 100 (prompt (+ 10 (shift k (k (k 1)))))) ~~> 121 *) -let example5 () : int = - Continuation_monad.(let v = reset ( - let u = shift (fun k -> k 1 >>= k) - in u >>= fun x -> unit (10 + x) - ) in let w = v >>= fun x -> unit (100 + x) - in run0 w) - -;; - -print_endline "=== test bare Continuation ============";; - -(1011, 1111, 1111, 121);; -(example1(), example2(), example3(), example5());; -((111,0), (0,0));; -(example ~+10, example ~-10);; - - -print_endline "=== pa_monad's Continuation Tests ============";; - -(1, 5 = C.(run0 (unit 1 >>= fun x -> unit (x+4))) );; -(2, 9 = C.(run0 (reset (unit 5 >>= fun x -> unit (x+4)))) );; -(3, 9 = C.(run0 (reset (abort 5 >>= fun y -> unit (y+6)) >>= fun x -> unit (x+4))) );; -(4, 9 = C.(run0 (reset (reset (abort 5 >>= fun y -> unit (y+6))) >>= fun x -> unit (x+4))) );; -(5, 27 = C.(run0 ( - let c = reset(abort 5 >>= fun y -> unit (y+6)) - in reset(c >>= fun v1 -> abort 7 >>= fun v2 -> unit (v2+10) ) >>= fun x -> unit (x+20))) );; - -(7, 117 = C.(run0 (reset (shift (fun sk -> sk 3 >>= sk >>= fun v3 -> unit (v3+100) ) >>= fun v1 -> unit (v1+2)) >>= fun x -> unit (x+10))) );; - -(8, 115 = C.(run0 (reset (shift (fun sk -> sk 3 >>= fun v3 -> unit (v3+100)) >>= fun v1 -> unit (v1+2)) >>= fun x -> unit (x+10))) );; - -(12, ["a"] = C.(run0 (reset (shift (fun f -> f [] >>= fun t -> unit ("a"::t) ) >>= fun xv -> shift (fun _ -> unit xv)))) );; - - -(0, 15 = C.(run0 (let f k = k 10 >>= fun v-> unit (v+100) in reset (callcc f >>= fun v -> unit (v+5)))) );; - -- 2.11.0