Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* ... *)
- (* 146 *) (** [apply_enum f x] applies [f] to [x] and converts exceptions
- (* 147 *) [No_more_input] and [Input_closed] to [BatEnum.No_more_elements]*)
- (* 148 *) let apply_enum do_close f x =
- (* 149 *) try f x
- (* 150 *) with
- (* 151 *) | No_more_input -> raise BatEnum.No_more_elements
- (* 152 *) | Input_closed -> do_close := false; raise BatEnum.No_more_elements
- (* 153 *)
- (* 154 *) (** [close_at_end input e] returns an enumeration which behaves as [e]
- (* 155 *) and has the secondary effect of closing [input] once everything has
- (* 156 *) been read.*)
- (* 157 *) let close_at_end do_close (input:input) e =
- (* 158 *) BatEnum.suffix_action (fun () -> if !do_close then close_in input) e
- (* 159 *)
- (* 160 *) let make_enum f input =
- (* 161 *) let do_close = ref true in
- (* 162 *) close_at_end do_close input (BatEnum.from (fun () -> apply_enum do_close f input))
- (* ... *)
- (* 482 *)(* make a bunch of char enums by reading buffer_size at a time and
- (* 483 *) concat them all into into one big char enum *)
- (* 484 *)let chars_of input =
- (* 485 *) let do_close = ref true in
- (* 486 *) close_at_end do_close input (BatEnum.concat (BatEnum.from (fun () ->
- (* 487 *) apply_enum do_close (fun source -> string_enum (nread source buffer_size)) input)))
- (* ... *)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement