Skip to content

Commit 7473a59

Browse files
committed
Don't use Seq.unfold for compatibility with ocaml < 4.11
1 parent 5991cd4 commit 7473a59

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

atdgen-runtime/src/util.ml

+8-1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ struct
8484
in
8585
input_file fname (fun ic -> from_channel ?buf ~fname:fname0 ?lnum read ic)
8686

87+
(* seq_unfold is Seq.unfold, needed for ocaml < 4.11 *)
88+
let rec seq_unfold f u () =
89+
match f u with
90+
| None -> Seq.Nil
91+
| Some (x, u') -> Seq.Cons (x, seq_unfold f u')
92+
8793
let seq_from_lexbuf ?(fin = fun () -> ()) read ls lexbuf =
8894
let f () =
8995
try
@@ -97,7 +103,8 @@ struct
97103
(try fin () with _ -> ());
98104
raise e
99105
in
100-
Seq.unfold f ()
106+
(* Seq.unfold is only available from ocaml 4.11 *)
107+
seq_unfold f ()
101108
102109
let seq_from_string ?buf ?fin ?fname ?lnum read ic =
103110
let lexbuf = Lexing.from_string ic in

0 commit comments

Comments
 (0)