Commits

camlspotter committed d032e92

added iter_lines_exn

Comments (0)

Files changed (2)

    We have to use `TRUE or `true instead.
 *)
 
+let iter_lines_exn fname f =
+  let ic = open_in fname in
+  protect () 
+    ~f:(fun () ->
+      let rec iter () = f (input_line ic); iter () in
+      try iter () with Exit | End_of_file -> ())
+    ~finally:(fun _ -> close_in ic)
+;;
+
 let iter_lines fname f =
-  catch () ~f:(fun () ->
-    let ic = open_in fname in
-    protect () 
-      ~f:(fun () ->
-        let rec iter () = f (input_line ic); iter () in
-        try iter () with Exit | End_of_file -> ())
-      ~finally:(fun _ -> close_in ic))
+  catch () ~f:(fun () -> iter_lines_exn fname f)
 ;;
 
 let to_lines fname =
 
 (** {6 Iterators over lines } *)
 
+val iter_lines_exn : string -> (string -> 'a) -> unit
+(** [iter_lines_exn filename f] iters [f] over lines of contets of [filename] *)
+
 val iter_lines : string -> (string -> unit) -> (unit, exn) result
 (** [iter_lines filename f] iters [f] over lines of contets of [filename] *)