(** This example illustrates that the multi-shot handlers in OCaml are leaky **)
type toss = Heads | Tails
effect Choose : bool
let choose () = perform Choose
let toss () = if (choose ())
then Heads
else Tails
let all_results m =
match m () with
| v -> [v]
| effect Choose k -> let k' = Obj.clone k in
(continue k true) @ (continue k' false)
let choose_not m =
match m () with
| v -> v
| effect Choose k -> let choice = choose () in
continue k (not choice)
let _ = all_results (fun () -> choose_not toss)