From 0b67b4641b54b8502878683ce57bc14b83ae6639 Mon Sep 17 00:00:00 2001 From: Fabian Date: Wed, 2 Jan 2019 08:07:08 +0100 Subject: [PATCH] Add from_labelled_iter --- src/Iter.ml | 2 ++ src/Iter.mli | 4 ++++ src/IterLabels.mli | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/src/Iter.ml b/src/Iter.ml index 9f7c6e5..1cd1b07 100644 --- a/src/Iter.ml +++ b/src/Iter.ml @@ -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 diff --git a/src/Iter.mli b/src/Iter.mli index db9e140..66cdc90 100644 --- a/src/Iter.mli +++ b/src/Iter.mli @@ -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! *) diff --git a/src/IterLabels.mli b/src/IterLabels.mli index 1f010ab..f0efd15 100644 --- a/src/IterLabels.mli +++ b/src/IterLabels.mli @@ -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! *)