Add from_labelled_iter

This commit is contained in:
Fabian 2019-01-02 08:07:08 +01:00 committed by Simon Cruanes
parent 843103a6d2
commit 0b67b4641b
3 changed files with 10 additions and 0 deletions

View file

@ -18,6 +18,8 @@ type 'a hash = 'a -> int
(** Build an iterator from a iter function *)
let from_iter f = f
let from_labelled_iter iter f = iter ~f
let rec from_fun f k = match f () with
| None -> ()
| Some x -> k x; from_fun f k

View file

@ -49,6 +49,10 @@ type 'a hash = 'a -> int
val from_iter : (('a -> unit) -> unit) -> 'a t
(** Build an iterator from a iter function *)
val from_labelled_iter : (f:('a -> unit) -> unit) -> 'a t
(** Build an iterator from a labelled iter function
@since NEXT_RELEASE *)
val from_fun : (unit -> 'a option) -> 'a t
(** Call the function repeatedly until it returns None. This
sequence is transient, use {!persistent} if needed! *)

View file

@ -25,6 +25,10 @@ type 'a hash = 'a -> int
val from_iter : (('a -> unit) -> unit) -> 'a t
(** Build an iterator from a iter function *)
val from_labelled_iter : (f:('a -> unit) -> unit) -> 'a t
(** Build an iterator from a labelled iter function
@since NEXT_RELEASE *)
val from_fun : (unit -> 'a option) -> 'a t
(** Call the function repeatedly until it returns None. This
sequence is transient, use {!persistent} if needed! *)