From 3d1286a19cf61fd87287493f24d553ed89ec60ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Hillerstr=C3=B6m?= Date: Tue, 9 Apr 2024 18:30:39 +0200 Subject: [PATCH] Slight tweak to the return example. --- examples/return.ml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/return.ml b/examples/return.ml index ccab644..91584ec 100644 --- a/examples/return.ml +++ b/examples/return.ml @@ -43,10 +43,12 @@ module Alg(D : sig type t end) : ALG with type t := D.t = struct let open Effect.Deep in let open Multicont.Deep in let conts = ref [] in - let pop () = + let backup ans = match !conts with - | cont :: conts' -> conts := conts'; cont - | _ -> assert false + | r :: conts' -> + conts := conts'; + resume r (Done ans) + | _ -> ans in let push r = conts := r :: !conts @@ -54,9 +56,7 @@ module Alg(D : sig type t end) : ALG with type t := D.t = struct { retc = (fun ans -> ans) ; exnc = (function - Return ans -> - let r = pop () in - resume r (Done ans) + Return ans -> backup ans | e -> raise e) ; effc = (fun (type a) (eff : a Effect.t) -> match eff with