- let newk = ref id in
- let rec loop () =
- let result = uthunk (newk := id) >>= chained
- in !newk result
- and chained =
- fun _ -> newk := (fun _ -> loop ()); z (* we use z only for its polymorphism *)
- in loop ()
- (* reimplementations of the preceding using a hand-rolled State or StateT also stack overflowed *)
+ let kcell = ref id in
+ let rec loop _ =
+ let result = uthunk (kcell := id) >>= chained
+ in !kcell result
+ and chained _ =
+ kcell := loop; z (* we use z only for its polymorphism *)
+ in loop z
+ (* Reimplementations of the preceding using a hand-rolled State or StateT
+can also stack overflow. *)