diff --git a/src/core/CCArray.ml b/src/core/CCArray.ml index 450fbe1d..b424be94 100644 --- a/src/core/CCArray.ml +++ b/src/core/CCArray.ml @@ -688,3 +688,12 @@ let sort_generic (type arr)(type elt) Array.sort CCInt.compare a1; sort_generic (module IA) ~cmp:CCInt.compare a2; \ a1 = a2 ) *) + + +module Infix = struct + let (>>=) = (>>=) + let (>>|) = (>>|) + let (>|=) = (>|=) + let (--) = (--) + let (--^) = (--^) +end diff --git a/src/core/CCArray.mli b/src/core/CCArray.mli index c707245e..fae4d03e 100644 --- a/src/core/CCArray.mli +++ b/src/core/CCArray.mli @@ -341,3 +341,30 @@ val sort_generic : (** [sort_generic (module M) ~cmp a] sorts the array [a], without allocating (eats stack space though). Performance might be lower than {!Array.sort}. @since 0.14 *) + + +(** {3 Infix Operators} *) + It is convenient to {!open CCArray.Infix} to access the infix operators + without cluttering the scope too much. + + @since 2.7 *) + +module Infix : sig + val (>>=) : 'a t -> ('a -> 'b t) -> 'b t + (** [a >>= f] is the infix version of {!flat_map}. *) + + val (>>|) : 'a t -> ('a -> 'b) -> 'b t + (** [a >>| f] is the infix version of {!map}. + @since 0.8 *) + + val (>|=) : 'a t -> ('a -> 'b) -> 'b t + (** [a >|= f] is the infix version of {!map}. + @since 0.8 *) + + val (--) : int -> int -> int t + (** [x -- y] creates an array containing integers in the range [x .. y]. Bounds included. *) + + val (--^) : int -> int -> int t + (** [x --^ y] creates an array containing integers in the range [x .. y]. Right bound excluded. + @since 0.17 *) +end diff --git a/src/core/CCArrayLabels.mli b/src/core/CCArrayLabels.mli index a8e6624f..0c96b340 100644 --- a/src/core/CCArrayLabels.mli +++ b/src/core/CCArrayLabels.mli @@ -342,3 +342,30 @@ val sort_generic : (** [sort_generic (module M) ~cmp a] sorts the array [a], without allocating (eats stack space though). Performance might be lower than {!Array.sort}. @since 0.14 *) + + +(** {3 Infix Operators} *) + It is convenient to {!open CCArray.Infix} to access the infix operators + without cluttering the scope too much. + + @since 2.7 *) + +module Infix : sig + val (>>=) : 'a t -> ('a -> 'b t) -> 'b t + (** [a >>= f] is the infix version of {!flat_map}. *) + + val (>>|) : 'a t -> ('a -> 'b) -> 'b t + (** [a >>| f] is the infix version of {!map}. + @since 0.8 *) + + val (>|=) : 'a t -> ('a -> 'b) -> 'b t + (** [a >|= f] is the infix version of {!map}. + @since 0.8 *) + + val (--) : int -> int -> int t + (** [x -- y] creates an array containing integers in the range [x .. y]. Bounds included. *) + + val (--^) : int -> int -> int t + (** [x --^ y] creates an array containing integers in the range [x .. y]. Right bound excluded. + @since 0.17 *) +end