From 632a820b1dfd88814413e50916071bc7cdaca5b2 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Tue, 1 Jul 2014 15:54:00 +0200 Subject: [PATCH] aliases to existing functions --- sequence.ml | 4 ++++ sequence.mli | 8 ++++++++ 2 files changed, 12 insertions(+) diff --git a/sequence.ml b/sequence.ml index 893f6c7..80631b8 100644 --- a/sequence.ml +++ b/sequence.ml @@ -129,6 +129,8 @@ let flatMap f seq = from_iter (fun k -> seq (fun x -> (f x) k)) +let flat_map = flatMap + let fmap f seq = from_iter (fun k -> @@ -136,6 +138,8 @@ let fmap f seq = | None -> () | Some y -> k y)) +let filter_map = fmap + (** Insert the given element between every element of the sequence *) let intersperse elem seq = fun k -> diff --git a/sequence.mli b/sequence.mli index 39444ee..f8f3d94 100644 --- a/sequence.mli +++ b/sequence.mli @@ -145,9 +145,17 @@ val flatMap : ('a -> 'b t) -> 'a t -> 'b t (** Monadic bind. Intuitively, it applies the function to every element of the initial sequence, and calls {!concat}. *) +val flat_map : ('a -> 'b t) -> 'a t -> 'b t + (** Alias to {!flatMap} with a more explicit name + @since NEXT_VERSION *) + val fmap : ('a -> 'b option) -> 'a t -> 'b t (** Specialized version of {!flatMap} for options. *) +val filter_map : ('a -> 'b option) -> 'a t -> 'b t + (** Alias to {!fmap} with a more explicit name + @since NEXT_VERSION *) + val intersperse : 'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *)