Given the following:
#light //any function returning bool * 'a let foo = let x = ref 10 fun () -> x := !x - 1 if !x <> 0 then (true, x) else (false, x) while let (c,x) = foo() in c do print_any x;//can't access x, but would be convinent. //this is how I want it to work, without all the typing let rec loop f = match f() with | (true, x) -> print_any x loop f | (false, _) -> () loop foo
How should I go about solving this? Or should I just go through the hassle to convert ‘foo’ to a sequence expression?
This is one solution, but I personally think it is abuse of the while construction.