Skip to content

Commit 8cb072f

Browse files
committed
Add support for OCaml 4.14
1 parent 3ae20e7 commit 8cb072f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

examples/blocking/blocking_example.ml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,12 @@ let connect () =
4040

4141
let stream res =
4242
let module F = struct exception E of M.error end in
43-
let next _ =
43+
let rec next () =
4444
match M.Res.fetch (module M.Row.Map) res with
45-
| Ok (Some _ as row) -> row
46-
| Ok None -> None
45+
| Ok (Some x) -> Seq.Cons (x, next)
46+
| Ok None -> Seq.Nil
4747
| Error e -> raise (F.E e) in
48-
try Ok (Stream.from next)
49-
with F.E e -> Error e
48+
next
5049

5150
let main () =
5251
let mariadb = connect () |> or_die "connect" in
@@ -56,8 +55,8 @@ let main () =
5655
let res = M.Stmt.execute stmt [| `String "r%" |] |> or_die "exec" in
5756
assert (M.Res.affected_rows res = M.Res.num_rows res);
5857
printf "#rows: %d\n%!" (M.Res.num_rows res);
59-
let s = stream res |> or_die "stream" in
60-
Stream.iter print_row s;
58+
let s = stream res in
59+
Seq.iter print_row s;
6160
M.Stmt.close stmt |> or_die "stmt close";
6261
M.close mariadb;
6362
M.library_end ();

0 commit comments

Comments
 (0)