diff --git a/sequence.ml b/sequence.ml index 3918f9b..4906b5d 100644 --- a/sequence.ml +++ b/sequence.ml @@ -109,6 +109,8 @@ let concat s = let k_seq seq = iter k seq in s k_seq) +let flatten s = concat s + (** Monadic bind. It applies the function to every element of the initial sequence, and calls [concat]. *) let flatMap f seq = diff --git a/sequence.mli b/sequence.mli index 646262f..6afcdfa 100644 --- a/sequence.mli +++ b/sequence.mli @@ -101,6 +101,9 @@ val append : 'a t -> 'a t -> 'a t val concat : 'a t t -> 'a t (** Concatenate a sequence of sequences into one sequence *) +val flatten : 'a t t -> 'a t + (** Alias for {!concat} *) + val flatMap : ('a -> 'b t) -> 'a t -> 'b t (** Monadic bind. It applies the function to every element of the initial sequence, and calls [concat]. *)