diff --git a/src/core/CCList.ml b/src/core/CCList.ml index bef9b423..76612fee 100644 --- a/src/core/CCList.ml +++ b/src/core/CCList.ml @@ -1081,6 +1081,15 @@ let of_klist l = in direct direct_depth_default_ l +module Infix = struct + let (>|=) = (>|=) + let (@) = (@) + let (<*>) = (<*>) + let (<$>) = (<$>) + let (>>=) = (>>=) + let (--) = (--) +end + (** {2 IO} *) let pp ?(start="[") ?(stop="]") ?(sep=", ") pp_item buf l = diff --git a/src/core/CCList.mli b/src/core/CCList.mli index ef7e0d3d..005507ae 100644 --- a/src/core/CCList.mli +++ b/src/core/CCList.mli @@ -465,6 +465,21 @@ val of_gen : 'a gen -> 'a t val to_klist : 'a t -> 'a klist val of_klist : 'a klist -> 'a t +(** {2 Infix Operators} + It is convenient to {!open CCList.Infix} to access the infix operators + without cluttering the scope too much. + + @since NEXT_RELEASE *) + +module Infix : sig + val (>|=) : 'a t -> ('a -> 'b) -> 'b t + val (@) : 'a t -> 'a t -> 'a t + val (<*>) : ('a -> 'b) t -> 'a t -> 'b t + val (<$>) : ('a -> 'b) -> 'a t -> 'b t + val (>>=) : 'a t -> ('a -> 'b t) -> 'b t + val (--) : int -> int -> int t +end + (** {2 IO} *) val pp : ?start:string -> ?stop:string -> ?sep:string -> diff --git a/src/core/CCOpt.ml b/src/core/CCOpt.ml index 4427e332..4753315d 100644 --- a/src/core/CCOpt.ml +++ b/src/core/CCOpt.ml @@ -123,6 +123,14 @@ let of_list = function | x::_ -> Some x | [] -> None +module Infix = struct + let (>|=) = (>|=) + let (>>=) = (>>=) + let (<*>) = (<*>) + let (<$>) = (<$>) + let (<+>) = (<+>) +end + type 'a sequence = ('a -> unit) -> unit type 'a gen = unit -> 'a option type 'a printer = Buffer.t -> 'a -> unit diff --git a/src/core/CCOpt.mli b/src/core/CCOpt.mli index f14ca823..63c763a8 100644 --- a/src/core/CCOpt.mli +++ b/src/core/CCOpt.mli @@ -93,6 +93,16 @@ val (<+>) : 'a t -> 'a t -> 'a t val choice : 'a t list -> 'a t (** [choice] returns the first non-[None] element of the list, or [None] *) +(** {2 Infix Operators} + @since NEXT_RELEASE *) + +module Infix : sig + val (>|=) : 'a t -> ('a -> 'b) -> 'b t + val (>>=) : 'a t -> ('a -> 'b t) -> 'b t + val (<*>) : ('a -> 'b) t -> 'a t -> 'b t + val (<$>) : ('a -> 'b) -> 'a t -> 'b t + val (<+>) : 'a t -> 'a t -> 'a t +end (** {2 Conversion and IO} *)