add {CCList,CCOpt}.Infix modules

This commit is contained in:
Simon Cruanes 2016-02-24 20:38:22 +01:00
parent 5cdf59f30c
commit 903dac110b
4 changed files with 42 additions and 0 deletions

View file

@ -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 =

View file

@ -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 ->

View file

@ -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

View file

@ -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} *)