prepare for 0.16

This commit is contained in:
Simon Cruanes 2016-02-24 22:08:26 +01:00
parent 8524f43120
commit a2179d4355
27 changed files with 150 additions and 94 deletions

View file

@ -1,5 +1,61 @@
= Changelog = Changelog
== 0.16
=== breaking
- change the signature of `CCHeap.{of_gen,of_seq,of_klist}`
- change the API of `CCMixmap`
- make type `CCHash.state` abstract (used to be `int64`)
- optional argument `~eq` to `CCGraph.Dot.pp`
- rename `CCFuture` into `CCPool`
=== deprecations
- deprecate `containers.bigarray`
- deprecate `CCHashtbl.{Counter,Default}` tables
- deprecate `CCLinq` in favor of standalone `OLinq` (to be released)
=== bugfixes
- fix wrong signature of `CCHashtbl.Make.{keys,values}_list`
- missing constraint in `CCSexpM.ID_MONAD`
=== new features
- add a tutorial file
- add a printer into CCHeap
- add `{CCList,CCOpt}.Infix` modules
- add `CCOpt.map_or`, deprecating `CCopt.maybe`
- add `CCFormat.sprintf_no_color`
- add `CCFormat.{h,v,hov,hv}box` printer combinators
- add `CCFormat.{with_color, with_colorf}`
- add `CCList.hd_tl`
- add `CCResult.{map_or,get_or}`
- add `CCGraph.make` and utils
- add `CCHashtbl.add_list`
- add counter function in `CCHashtbl`, to replace `CCHashtbl.Counter`
- add `CCPair.make`
- add `CCString.Split.{left,right}_exn`
- add `CCIO.File.{read,write,append}` for quickly handling files
- add `CCRandom.pick_{list,array}`
- add `CCList.Assoc.update`
- add `CCList.Assoc.mem`
- add `{CCMap,CCHashtbl}.get_or` for lookup with default value
- add `CCLock.{decr_then_get, get_then_{decr,set,clear}}`
- rename `CCFuture` into `CCPool`, expose the thread pool
- split `CCTimer` out of `CCFuture`, a standalone 1-thread timer
- move `CCThread.Queue` into `CCBlockingQueue`
- add `CCResult`, with dependency on `result` for retrocompat
- add `CCThread.spawn{1,2}`
- add many helpers in `CCUnix` (for sockets, files, and processes)
- add `CCFun.finally{1,2}`, convenience around `finally`
- add `CCLock.update_map`
- add `CCLock.{incr_then_get,get_then_incr}`
- add breaking space in `CCFormat.{pair,triple,quad}`
- update `examples/id_sexp` so it can read on stdin
- add `CCList.fold_map2`
== 0.15 == 0.15
=== breaking changes === breaking changes
@ -15,7 +71,7 @@
- add `CCMap.{keys,values}` - add `CCMap.{keys,values}`
- add wip `CCAllocCache`, an allocation cache for short-lived arrays - add wip `CCAllocCache`, an allocation cache for short-lived arrays
- add `CCError.{join,both}` applicative functions for CCError - add `CCError.{join,both}` applicative functions for CCError
- opam: depend on ocamlbuild - opam: depend on ecamlbuild
- work on `CCRandom` by octachron: - work on `CCRandom` by octachron:
* add an uniformity test * add an uniformity test
* Make `split_list` uniform * Make `split_list` uniform

2
_oasis
View file

@ -1,6 +1,6 @@
OASISFormat: 0.4 OASISFormat: 0.4
Name: containers Name: containers
Version: 0.15 Version: 0.16
Homepage: https://github.com/c-cube/ocaml-containers Homepage: https://github.com/c-cube/ocaml-containers
Authors: Simon Cruanes Authors: Simon Cruanes
License: BSD-2-clause License: BSD-2-clause

View file

@ -47,21 +47,21 @@ val map : ('a -> 'b) -> 'b printer -> 'a printer
val vbox : ?i:int -> 'a printer -> 'a printer val vbox : ?i:int -> 'a printer -> 'a printer
(** Wrap the printer in a vertical box (** Wrap the printer in a vertical box
@param i level of indentation within the box (default 0) @param i level of indentation within the box (default 0)
@since NEXT_RELEASE *) @since 0.16 *)
val hvbox : ?i:int -> 'a printer -> 'a printer val hvbox : ?i:int -> 'a printer -> 'a printer
(** Wrap the printer in a horizontal/vertical box (** Wrap the printer in a horizontal/vertical box
@param i level of indentation within the box (default 0) @param i level of indentation within the box (default 0)
@since NEXT_RELEASE *) @since 0.16 *)
val hovbox : ?i:int -> 'a printer -> 'a printer val hovbox : ?i:int -> 'a printer -> 'a printer
(** Wrap the printer in a horizontal or vertical box (** Wrap the printer in a horizontal or vertical box
@param i level of indentation within the box (default 0) @param i level of indentation within the box (default 0)
@since NEXT_RELEASE *) @since 0.16 *)
val hbox : 'a printer -> 'a printer val hbox : 'a printer -> 'a printer
(** Wrap the printer in an horizontal box (** Wrap the printer in an horizontal box
@since NEXT_RELEASE *) @since 0.16 *)
(** {2 ANSI codes} (** {2 ANSI codes}
@ -117,13 +117,13 @@ val with_color : string -> 'a printer -> 'a printer
(** [with_color "Blue" pp] behaves like the printer [pp], but with the given (** [with_color "Blue" pp] behaves like the printer [pp], but with the given
style. style.
{b status: experimental} {b status: experimental}
@since NEXT_RELEASE *) @since 0.16 *)
val with_colorf : string -> t -> ('a, t, unit, unit) format4 -> 'a val with_colorf : string -> t -> ('a, t, unit, unit) format4 -> 'a
(** [with_colorf "Blue" out "%s %d" "yolo" 42] will behave like {!Format.fprintf}, (** [with_colorf "Blue" out "%s %d" "yolo" 42] will behave like {!Format.fprintf},
but wrapping the content with the given style but wrapping the content with the given style
{b status: experimental} {b status: experimental}
@since NEXT_RELEASE *) @since 0.16 *)
(** {2 IO} *) (** {2 IO} *)
@ -139,7 +139,7 @@ val sprintf : ('a, t, unit, string) format4 -> 'a
val sprintf_no_color : ('a, t, unit, string) format4 -> 'a val sprintf_no_color : ('a, t, unit, string) format4 -> 'a
(** Similar to {!sprintf} but never prints colors (** Similar to {!sprintf} but never prints colors
@since NEXT_RELEASE *) @since 0.16 *)
val fprintf : t -> ('a, t, unit ) format -> 'a val fprintf : t -> ('a, t, unit ) format -> 'a
(** Alias to {!Format.fprintf} (** Alias to {!Format.fprintf}

View file

@ -58,12 +58,12 @@ val finally : h:(unit -> _) -> f:(unit -> 'a) -> 'a
val finally1 : h:(unit -> _) -> ('a -> 'b) -> 'a -> 'b val finally1 : h:(unit -> _) -> ('a -> 'b) -> 'a -> 'b
(** [finally1 ~h f x] is the same as [f x], but after the computation, (** [finally1 ~h f x] is the same as [f x], but after the computation,
[h ()] is called whether [f x] rose an exception or not. [h ()] is called whether [f x] rose an exception or not.
@since NEXT_RELEASE *) @since 0.16 *)
val finally2 : h:(unit -> _) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c val finally2 : h:(unit -> _) -> ('a -> 'b -> 'c) -> 'a -> 'b -> 'c
(** [finally2 ~h f x y] is the same as [f x y], but after the computation, (** [finally2 ~h f x y] is the same as [f x y], but after the computation,
[h ()] is called whether [f x y] rose an exception or not. [h ()] is called whether [f x y] rose an exception or not.
@since NEXT_RELEASE *) @since 0.16 *)
(** {2 Monad} (** {2 Monad}

View file

@ -10,7 +10,7 @@ type t = int
type state type state
(** State required by the hash function. (** State required by the hash function.
@since NEXT_RELEASE the state is abstract, for more flexibility *) @since 0.16 the state is abstract, for more flexibility *)
type 'a hash_fun = 'a -> state -> state type 'a hash_fun = 'a -> state -> state
(** Hash function for values of type ['a], merging a fingerprint of the (** Hash function for values of type ['a], merging a fingerprint of the

View file

@ -127,25 +127,25 @@ module type S = sig
val get_or : 'a t -> key -> or_:'a -> 'a val get_or : 'a t -> key -> or_:'a -> 'a
(** [get_or tbl k ~or_] returns the value associated to [k] if present, (** [get_or tbl k ~or_] returns the value associated to [k] if present,
and returns [or_] otherwise (if [k] doesn't belong in [tbl]) and returns [or_] otherwise (if [k] doesn't belong in [tbl])
@since NEXT_RELEASE *) @since 0.16 *)
val add_list : 'a list t -> key -> 'a -> unit val add_list : 'a list t -> key -> 'a -> unit
(** [add_list tbl x y] adds [y] to the list [x] is bound to. If [x] is (** [add_list tbl x y] adds [y] to the list [x] is bound to. If [x] is
not bound, it becomes bound to [[y]]. not bound, it becomes bound to [[y]].
@since NEXT_RELEASE *) @since 0.16 *)
val incr : ?by:int -> int t -> key -> unit val incr : ?by:int -> int t -> key -> unit
(** [incr ?by tbl x] increments or initializes the counter associated with [x]. (** [incr ?by tbl x] increments or initializes the counter associated with [x].
If [get tbl x = None], then after update, [get tbl x = Some 1]; If [get tbl x = None], then after update, [get tbl x = Some 1];
otherwise, if [get tbl x = Some n], now [get tbl x = Some (n+1)]. otherwise, if [get tbl x = Some n], now [get tbl x = Some (n+1)].
@param by if specified, the int value is incremented by [by] rather than 1 @param by if specified, the int value is incremented by [by] rather than 1
@since NEXT_RELEASE *) @since 0.16 *)
val decr : ?by:int -> int t -> key -> unit val decr : ?by:int -> int t -> key -> unit
(** Same as {!incr} but substract 1 (or the value of [by]). (** Same as {!incr} but substract 1 (or the value of [by]).
If the value reaches 0, the key is removed from the table. If the value reaches 0, the key is removed from the table.
This does nothing if the key is not already present in the table. This does nothing if the key is not already present in the table.
@since NEXT_RELEASE *) @since 0.16 *)
val keys : 'a t -> key sequence val keys : 'a t -> key sequence
(** Iterate on keys (similar order as {!Hashtbl.iter}) *) (** Iterate on keys (similar order as {!Hashtbl.iter}) *)
@ -172,17 +172,17 @@ module type S = sig
val add_seq : 'a t -> (key * 'a) sequence -> unit val add_seq : 'a t -> (key * 'a) sequence -> unit
(** Add the corresponding pairs to the table, using {!Hashtbl.add}. (** Add the corresponding pairs to the table, using {!Hashtbl.add}.
@since NEXT_RELEASE *) @since 0.16 *)
val add_seq_count : int t -> key sequence -> unit val add_seq_count : int t -> key sequence -> unit
(** [add_seq_count tbl seq] increments the count of each element of [seq] (** [add_seq_count tbl seq] increments the count of each element of [seq]
by calling {!incr}. This is useful for counting how many times each by calling {!incr}. This is useful for counting how many times each
element of [seq] occurs. element of [seq] occurs.
@since NEXT_RELEASE *) @since 0.16 *)
val of_seq_count : key sequence -> int t val of_seq_count : key sequence -> int t
(** Similar to {!add_seq_count}, but allocates a new table and returns it (** Similar to {!add_seq_count}, but allocates a new table and returns it
@since NEXT_RELEASE *) @since 0.16 *)
val to_list : 'a t -> (key * 'a) list val to_list : 'a t -> (key * 'a) list
(** List of bindings (order unspecified) *) (** List of bindings (order unspecified) *)

View file

@ -18,7 +18,7 @@ val get : ('a,'b) Hashtbl.t -> 'a -> 'b option
val get_or : ('a,'b) Hashtbl.t -> 'a -> or_:'b -> 'b val get_or : ('a,'b) Hashtbl.t -> 'a -> or_:'b -> 'b
(** [get_or tbl k ~or_] returns the value associated to [k] if present, (** [get_or tbl k ~or_] returns the value associated to [k] if present,
and returns [or_] otherwise (if [k] doesn't belong in [tbl]) and returns [or_] otherwise (if [k] doesn't belong in [tbl])
@since NEXT_RELEASE *) @since 0.16 *)
val keys : ('a,'b) Hashtbl.t -> 'a sequence val keys : ('a,'b) Hashtbl.t -> 'a sequence
(** Iterate on keys (similar order as {!Hashtbl.iter}) *) (** Iterate on keys (similar order as {!Hashtbl.iter}) *)
@ -42,13 +42,13 @@ val incr : ?by:int -> ('a, int) Hashtbl.t -> 'a -> unit
If [get tbl x = None], then after update, [get tbl x = Some 1]; If [get tbl x = None], then after update, [get tbl x = Some 1];
otherwise, if [get tbl x = Some n], now [get tbl x = Some (n+1)]. otherwise, if [get tbl x = Some n], now [get tbl x = Some (n+1)].
@param by if specified, the int value is incremented by [by] rather than 1 @param by if specified, the int value is incremented by [by] rather than 1
@since NEXT_RELEASE *) @since 0.16 *)
val decr : ?by:int -> ('a, int) Hashtbl.t -> 'a -> unit val decr : ?by:int -> ('a, int) Hashtbl.t -> 'a -> unit
(** Same as {!incr} but substract 1 (or the value of [by]). (** Same as {!incr} but substract 1 (or the value of [by]).
If the value reaches 0, the key is removed from the table. If the value reaches 0, the key is removed from the table.
This does nothing if the key is not already present in the table. This does nothing if the key is not already present in the table.
@since NEXT_RELEASE *) @since 0.16 *)
val to_seq : ('a,'b) Hashtbl.t -> ('a * 'b) sequence val to_seq : ('a,'b) Hashtbl.t -> ('a * 'b) sequence
(** Iterate on bindings in the table *) (** Iterate on bindings in the table *)
@ -56,11 +56,11 @@ val to_seq : ('a,'b) Hashtbl.t -> ('a * 'b) sequence
val add_list : ('a, 'b list) Hashtbl.t -> 'a -> 'b -> unit val add_list : ('a, 'b list) Hashtbl.t -> 'a -> 'b -> unit
(** [add_list tbl x y] adds [y] to the list [x] is bound to. If [x] is (** [add_list tbl x y] adds [y] to the list [x] is bound to. If [x] is
not bound, it becomes bound to [[y]]. not bound, it becomes bound to [[y]].
@since NEXT_RELEASE *) @since 0.16 *)
val add_seq : ('a,'b) Hashtbl.t -> ('a * 'b) sequence -> unit val add_seq : ('a,'b) Hashtbl.t -> ('a * 'b) sequence -> unit
(** Add the corresponding pairs to the table, using {!Hashtbl.add}. (** Add the corresponding pairs to the table, using {!Hashtbl.add}.
@since NEXT_RELEASE *) @since 0.16 *)
val of_seq : ('a * 'b) sequence -> ('a,'b) Hashtbl.t val of_seq : ('a * 'b) sequence -> ('a,'b) Hashtbl.t
(** From the given bindings, added in order *) (** From the given bindings, added in order *)
@ -69,11 +69,11 @@ val add_seq_count : ('a, int) Hashtbl.t -> 'a sequence -> unit
(** [add_seq_count tbl seq] increments the count of each element of [seq] (** [add_seq_count tbl seq] increments the count of each element of [seq]
by calling {!incr}. This is useful for counting how many times each by calling {!incr}. This is useful for counting how many times each
element of [seq] occurs. element of [seq] occurs.
@since NEXT_RELEASE *) @since 0.16 *)
val of_seq_count : 'a sequence -> ('a, int) Hashtbl.t val of_seq_count : 'a sequence -> ('a, int) Hashtbl.t
(** Similar to {!add_seq_count}, but allocates a new table and returns it (** Similar to {!add_seq_count}, but allocates a new table and returns it
@since NEXT_RELEASE *) @since 0.16 *)
val to_list : ('a,'b) Hashtbl.t -> ('a * 'b) list val to_list : ('a,'b) Hashtbl.t -> ('a * 'b) list
(** List of bindings (order unspecified) *) (** List of bindings (order unspecified) *)
@ -104,25 +104,25 @@ module type S = sig
val get_or : 'a t -> key -> or_:'a -> 'a val get_or : 'a t -> key -> or_:'a -> 'a
(** [get_or tbl k ~or_] returns the value associated to [k] if present, (** [get_or tbl k ~or_] returns the value associated to [k] if present,
and returns [or_] otherwise (if [k] doesn't belong in [tbl]) and returns [or_] otherwise (if [k] doesn't belong in [tbl])
@since NEXT_RELEASE *) @since 0.16 *)
val add_list : 'a list t -> key -> 'a -> unit val add_list : 'a list t -> key -> 'a -> unit
(** [add_list tbl x y] adds [y] to the list [x] is bound to. If [x] is (** [add_list tbl x y] adds [y] to the list [x] is bound to. If [x] is
not bound, it becomes bound to [[y]]. not bound, it becomes bound to [[y]].
@since NEXT_RELEASE *) @since 0.16 *)
val incr : ?by:int -> int t -> key -> unit val incr : ?by:int -> int t -> key -> unit
(** [incr ?by tbl x] increments or initializes the counter associated with [x]. (** [incr ?by tbl x] increments or initializes the counter associated with [x].
If [get tbl x = None], then after update, [get tbl x = Some 1]; If [get tbl x = None], then after update, [get tbl x = Some 1];
otherwise, if [get tbl x = Some n], now [get tbl x = Some (n+1)]. otherwise, if [get tbl x = Some n], now [get tbl x = Some (n+1)].
@param by if specified, the int value is incremented by [by] rather than 1 @param by if specified, the int value is incremented by [by] rather than 1
@since NEXT_RELEASE *) @since 0.16 *)
val decr : ?by:int -> int t -> key -> unit val decr : ?by:int -> int t -> key -> unit
(** Same as {!incr} but substract 1 (or the value of [by]). (** Same as {!incr} but substract 1 (or the value of [by]).
If the value reaches 0, the key is removed from the table. If the value reaches 0, the key is removed from the table.
This does nothing if the key is not already present in the table. This does nothing if the key is not already present in the table.
@since NEXT_RELEASE *) @since 0.16 *)
val keys : 'a t -> key sequence val keys : 'a t -> key sequence
(** Iterate on keys (similar order as {!Hashtbl.iter}) *) (** Iterate on keys (similar order as {!Hashtbl.iter}) *)
@ -149,17 +149,17 @@ module type S = sig
val add_seq : 'a t -> (key * 'a) sequence -> unit val add_seq : 'a t -> (key * 'a) sequence -> unit
(** Add the corresponding pairs to the table, using {!Hashtbl.add}. (** Add the corresponding pairs to the table, using {!Hashtbl.add}.
@since NEXT_RELEASE *) @since 0.16 *)
val add_seq_count : int t -> key sequence -> unit val add_seq_count : int t -> key sequence -> unit
(** [add_seq_count tbl seq] increments the count of each element of [seq] (** [add_seq_count tbl seq] increments the count of each element of [seq]
by calling {!incr}. This is useful for counting how many times each by calling {!incr}. This is useful for counting how many times each
element of [seq] occurs. element of [seq] occurs.
@since NEXT_RELEASE *) @since 0.16 *)
val of_seq_count : key sequence -> int t val of_seq_count : key sequence -> int t
(** Similar to {!add_seq_count}, but allocates a new table and returns it (** Similar to {!add_seq_count}, but allocates a new table and returns it
@since NEXT_RELEASE *) @since 0.16 *)
val to_list : 'a t -> (key * 'a) list val to_list : 'a t -> (key * 'a) list
(** List of bindings (order unspecified) *) (** List of bindings (order unspecified) *)
@ -187,7 +187,7 @@ module Make(X : Hashtbl.HashedType) :
A table with a default element for keys that were never added. A table with a default element for keys that were never added.
@deprecated since NEXT_RELEASE, should be merged into [Make] itself *) @deprecated since 0.16, should be merged into [Make] itself *)
module type DEFAULT = sig module type DEFAULT = sig
type key type key
@ -223,7 +223,7 @@ module MakeDefault(X : Hashtbl.HashedType) : DEFAULT with type key = X.t
(** {2 Count occurrences using a Hashtbl} (** {2 Count occurrences using a Hashtbl}
@deprecated since NEXT_RELEASE, should be merged into [Make] itself *) @deprecated since 0.16, should be merged into [Make] itself *)
module type COUNTER = sig module type COUNTER = sig
type elt type elt

View file

@ -116,28 +116,28 @@ module type S = sig
(** {2 Conversions} (** {2 Conversions}
The interface of [of_gen], [of_seq], [of_klist] The interface of [of_gen], [of_seq], [of_klist]
has changed @since NEXT_RELEASE (the old signatures has changed @since 0.16 (the old signatures
are now [add_seq], [add_gen], [add_klist]) *) are now [add_seq], [add_gen], [add_klist]) *)
val to_list : t -> elt list val to_list : t -> elt list
val add_list : t -> elt list -> t (** @since NEXT_RELEASE *) val add_list : t -> elt list -> t (** @since 0.16 *)
val of_list : elt list -> t val of_list : elt list -> t
val add_seq : t -> elt sequence -> t (** @since NEXT_RELEASE *) val add_seq : t -> elt sequence -> t (** @since 0.16 *)
val of_seq : elt sequence -> t val of_seq : elt sequence -> t
val to_seq : t -> elt sequence val to_seq : t -> elt sequence
val add_klist : t -> elt klist -> t (** @since NEXT_RELEASE *) val add_klist : t -> elt klist -> t (** @since 0.16 *)
val of_klist : elt klist -> t val of_klist : elt klist -> t
val to_klist : t -> elt klist val to_klist : t -> elt klist
val add_gen : t -> elt gen -> t (** @since NEXT_RELEASE *) val add_gen : t -> elt gen -> t (** @since 0.16 *)
val of_gen : elt gen -> t val of_gen : elt gen -> t
@ -146,7 +146,7 @@ module type S = sig
val to_tree : t -> elt ktree val to_tree : t -> elt ktree
val print : ?sep:string -> elt printer -> t printer val print : ?sep:string -> elt printer -> t printer
(** @since NEXT_RELEASE *) (** @since 0.16 *)
end end
module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct module Make(E : PARTIAL_ORD) : S with type elt = E.t = struct

View file

@ -67,28 +67,28 @@ module type S = sig
(** {2 Conversions} (** {2 Conversions}
The interface of [of_gen], [of_seq], [of_klist] The interface of [of_gen], [of_seq], [of_klist]
has changed @since NEXT_RELEASE (the old signatures has changed @since 0.16 (the old signatures
are now [add_seq], [add_gen], [add_klist]) *) are now [add_seq], [add_gen], [add_klist]) *)
val to_list : t -> elt list val to_list : t -> elt list
val add_list : t -> elt list -> t (** @since NEXT_RELEASE *) val add_list : t -> elt list -> t (** @since 0.16 *)
val of_list : elt list -> t val of_list : elt list -> t
val add_seq : t -> elt sequence -> t (** @since NEXT_RELEASE *) val add_seq : t -> elt sequence -> t (** @since 0.16 *)
val of_seq : elt sequence -> t val of_seq : elt sequence -> t
val to_seq : t -> elt sequence val to_seq : t -> elt sequence
val add_klist : t -> elt klist -> t (** @since NEXT_RELEASE *) val add_klist : t -> elt klist -> t (** @since 0.16 *)
val of_klist : elt klist -> t val of_klist : elt klist -> t
val to_klist : t -> elt klist val to_klist : t -> elt klist
val add_gen : t -> elt gen -> t (** @since NEXT_RELEASE *) val add_gen : t -> elt gen -> t (** @since 0.16 *)
val of_gen : elt gen -> t val of_gen : elt gen -> t
@ -97,7 +97,7 @@ module type S = sig
val to_tree : t -> elt ktree val to_tree : t -> elt ktree
val print : ?sep:string -> elt printer -> t printer val print : ?sep:string -> elt printer -> t printer
(** @since NEXT_RELEASE *) (** @since 0.16 *)
end end
module Make(E : PARTIAL_ORD) : S with type elt = E.t module Make(E : PARTIAL_ORD) : S with type elt = E.t

View file

@ -164,27 +164,27 @@ module File : sig
val read_exn : t -> string val read_exn : t -> string
(** Read the content of the given file, or raises some exception (** Read the content of the given file, or raises some exception
@since NEXT_RELEASE *) @since 0.16 *)
val read : t -> string or_error val read : t -> string or_error
(** Read the content of the given file (** Read the content of the given file
@since NEXT_RELEASE *) @since 0.16 *)
val append_exn : t -> string -> unit val append_exn : t -> string -> unit
(** Append the given string into the given file, possibly raising (** Append the given string into the given file, possibly raising
@since NEXT_RELEASE *) @since 0.16 *)
val append : t -> string -> unit or_error val append : t -> string -> unit or_error
(** Append the given string into the given file (** Append the given string into the given file
@since NEXT_RELEASE *) @since 0.16 *)
val write_exn : t -> string -> unit val write_exn : t -> string -> unit
(** Write the given string into the given file, possibly raising (** Write the given string into the given file, possibly raising
@since NEXT_RELEASE *) @since 0.16 *)
val write : t -> string -> unit or_error val write : t -> string -> unit or_error
(** Write the given string into the given file (** Write the given string into the given file
@since NEXT_RELEASE *) @since 0.16 *)
type walk_item = [`File | `Dir] * t type walk_item = [`File | `Dir] * t

View file

@ -51,7 +51,7 @@ val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list
val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list val fold_map2 : ('acc -> 'a -> 'b -> 'acc * 'c) -> 'acc -> 'a list -> 'b list -> 'acc * 'c list
(** [fold_map2] is to [fold_map] what [List.map2] is to [List.map]. (** [fold_map2] is to [fold_map] what [List.map2] is to [List.map].
@raise Invalid_argument if the lists do not have the same length @raise Invalid_argument if the lists do not have the same length
@since NEXT_RELEASE *) @since 0.16 *)
val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list val fold_flat_map : ('acc -> 'a -> 'acc * 'b list) -> 'acc -> 'a list -> 'acc * 'b list
(** [fold_flat_map f acc l] is a [fold_left]-like function, but it also maps the (** [fold_flat_map f acc l] is a [fold_left]-like function, but it also maps the
@ -109,7 +109,7 @@ val drop : int -> 'a t -> 'a t
val hd_tl : 'a t -> 'a * 'a t val hd_tl : 'a t -> 'a * 'a t
(** [hd_tl (x :: l)] returns [hd, l]. (** [hd_tl (x :: l)] returns [hd, l].
@raise Failure if the list is empty @raise Failure if the list is empty
@since NEXT_RELEASE *) @since 0.16 *)
val take_drop : int -> 'a t -> 'a t * 'a t val take_drop : int -> 'a t -> 'a t * 'a t
(** [take_drop n l] returns [l1, l2] such that [l1 @ l2 = l] and (** [take_drop n l] returns [l1, l2] such that [l1 @ l2 = l] and
@ -286,14 +286,14 @@ module Assoc : sig
val mem : ?eq:('a->'a->bool) -> ('a,_) t -> 'a -> bool val mem : ?eq:('a->'a->bool) -> ('a,_) t -> 'a -> bool
(** [mem l x] returns [true] iff [x] is a key in [l] (** [mem l x] returns [true] iff [x] is a key in [l]
@since NEXT_RELEASE *) @since 0.16 *)
val update : val update :
?eq:('a->'a->bool) -> ('a,'b) t -> 'a -> f:('b option -> 'b option) -> ('a,'b) t ?eq:('a->'a->bool) -> ('a,'b) t -> 'a -> f:('b option -> 'b option) -> ('a,'b) t
(** [update l k ~f] updates [l] on the key [k], by calling [f (get l k)] (** [update l k ~f] updates [l] on the key [k], by calling [f (get l k)]
and removing [k] if it returns [None], mapping [k] to [v'] if it and removing [k] if it returns [None], mapping [k] to [v'] if it
returns [Some v'] returns [Some v']
@since NEXT_RELEASE *) @since 0.16 *)
end end
(** {2 Zipper} *) (** {2 Zipper} *)
@ -469,7 +469,7 @@ val of_klist : 'a klist -> 'a t
It is convenient to {!open CCList.Infix} to access the infix operators It is convenient to {!open CCList.Infix} to access the infix operators
without cluttering the scope too much. without cluttering the scope too much.
@since NEXT_RELEASE *) @since 0.16 *)
module Infix : sig module Infix : sig
val (>|=) : 'a t -> ('a -> 'b) -> 'b t val (>|=) : 'a t -> ('a -> 'b) -> 'b t

View file

@ -16,7 +16,7 @@ module type S = sig
val get_or : key -> 'a t -> or_:'a -> 'a val get_or : key -> 'a t -> or_:'a -> 'a
(** [get_or k m ~or_] returns the value associated to [k] if present, (** [get_or k m ~or_] returns the value associated to [k] if present,
and returns [or_] otherwise (if [k] doesn't belong in [m]) and returns [or_] otherwise (if [k] doesn't belong in [m])
@since NEXT_RELEASE *) @since 0.16 *)
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t val update : key -> ('a option -> 'a option) -> 'a t -> 'a t
(** [update k f m] calls [f (Some v)] if [find k m = v], (** [update k f m] calls [f (Some v)] if [find k m = v],

View file

@ -19,7 +19,7 @@ module type S = sig
val get_or : key -> 'a t -> or_:'a -> 'a val get_or : key -> 'a t -> or_:'a -> 'a
(** [get_or k m ~or_] returns the value associated to [k] if present, (** [get_or k m ~or_] returns the value associated to [k] if present,
and returns [or_] otherwise (if [k] doesn't belong in [m]) and returns [or_] otherwise (if [k] doesn't belong in [m])
@since NEXT_RELEASE *) @since 0.16 *)
val update : key -> ('a option -> 'a option) -> 'a t -> 'a t val update : key -> ('a option -> 'a option) -> 'a t -> 'a t
(** [update k f m] calls [f (Some v)] if [find k m = v], (** [update k f m] calls [f (Some v)] if [find k m = v],

View file

@ -15,7 +15,7 @@ val maybe : ('a -> 'b) -> 'b -> 'a t -> 'b
val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b
(** [map_or ~default f o] is [f x] if [o = Some x], [default otherwise] (** [map_or ~default f o] is [f x] if [o = Some x], [default otherwise]
@since NEXT_RELEASE *) @since 0.16 *)
val is_some : _ t -> bool val is_some : _ t -> bool
@ -94,7 +94,7 @@ val (<+>) : 'a t -> 'a t -> 'a t
val choice : 'a t list -> 'a t val choice : 'a t list -> 'a t
(** [choice] returns the first non-[None] element of the list, or [None] *) (** [choice] returns the first non-[None] element of the list, or [None] *)
(** {2 Infix Operators} (** {2 Infix Operators}
@since NEXT_RELEASE *) @since 0.16 *)
module Infix : sig module Infix : sig
val (>|=) : 'a t -> ('a -> 'b) -> 'b t val (>|=) : 'a t -> ('a -> 'b) -> 'b t

View file

@ -7,7 +7,7 @@ type ('a,'b) t = ('a * 'b)
val make : 'a -> 'b -> ('a, 'b) t val make : 'a -> 'b -> ('a, 'b) t
(** Make a tuple from its components (** Make a tuple from its components
@since NEXT_RELEASE *) @since 0.16 *)
val map1 : ('a -> 'b) -> ('a * 'c) -> ('b * 'c) val map1 : ('a -> 'b) -> ('a * 'c) -> ('b * 'c)

View file

@ -65,17 +65,17 @@ val list_seq : 'a t list -> 'a list t
@since 0.4 *) @since 0.4 *)
exception Pick_from_empty exception Pick_from_empty
(** @since NEXT_RELEASE *) (** @since 0.16 *)
val pick_list : 'a list -> 'a t val pick_list : 'a list -> 'a t
(** Pick an element at random from the list (** Pick an element at random from the list
@raise Pick_from_empty if the list is empty @raise Pick_from_empty if the list is empty
@since NEXT_RELEASE *) @since 0.16 *)
val pick_array : 'a array -> 'a t val pick_array : 'a array -> 'a t
(** Pick an element at random from the array (** Pick an element at random from the array
@raise Pick_from_empty if the array is empty @raise Pick_from_empty if the array is empty
@since NEXT_RELEASE *) @since 0.16 *)
val small_int : int t val small_int : int t

View file

@ -5,7 +5,7 @@
Uses the new "result" type from OCaml 4.03. Uses the new "result" type from OCaml 4.03.
@since NEXT_RELEASE *) @since 0.16 *)
type 'a sequence = ('a -> unit) -> unit type 'a sequence = ('a -> unit) -> unit
type 'a equal = 'a -> 'a -> bool type 'a equal = 'a -> 'a -> bool

View file

@ -302,7 +302,7 @@ module Split : sig
val left_exn : by:string -> string -> string * string val left_exn : by:string -> string -> string * string
(** Split on the first occurrence of [by] from the leftmost part of the string (** Split on the first occurrence of [by] from the leftmost part of the string
@raise Not_found if [by] is not part of the string @raise Not_found if [by] is not part of the string
@since NEXT_RELEASE *) @since 0.16 *)
(*$T (*$T
Split.left ~by:" " "ab cde f g " = Some ("ab", "cde f g ") Split.left ~by:" " "ab cde f g " = Some ("ab", "cde f g ")
@ -317,7 +317,7 @@ module Split : sig
val right_exn : by:string -> string -> string * string val right_exn : by:string -> string -> string * string
(** Split on the first occurrence of [by] from the rightmost part of the string (** Split on the first occurrence of [by] from the rightmost part of the string
@raise Not_found if [by] is not part of the string @raise Not_found if [by] is not part of the string
@since NEXT_RELEASE *) @since 0.16 *)
(*$T (*$T
Split.right ~by:" " "ab cde f g" = Some ("ab cde f", "g") Split.right ~by:" " "ab cde f g" = Some ("ab cde f", "g")

View file

@ -81,17 +81,17 @@ val make :
dest:('e -> 'v) -> dest:('e -> 'v) ->
('v -> 'e sequence) -> ('v, 'e) t ('v -> 'e sequence) -> ('v, 'e) t
(** Make a graph by providing its fields (** Make a graph by providing its fields
@since NEXT_RELEASE *) @since 0.16 *)
val make_labelled_tuple : val make_labelled_tuple :
('v -> ('a * 'v) sequence) -> ('v, ('v * 'a * 'v)) t ('v -> ('a * 'v) sequence) -> ('v, ('v * 'a * 'v)) t
(** Make a graph with edges being triples [(origin,label,dest)] (** Make a graph with edges being triples [(origin,label,dest)]
@since NEXT_RELEASE *) @since 0.16 *)
val make_tuple : val make_tuple :
('v -> 'v sequence) -> ('v, ('v * 'v)) t ('v -> 'v sequence) -> ('v, ('v * 'v)) t
(** Make a graph with edges being pairs [(origin,dest)] (** Make a graph with edges being pairs [(origin,dest)]
@since NEXT_RELEASE *) @since 0.16 *)
(** Mutable tags from values of type ['v] to tags of type [bool] *) (** Mutable tags from values of type ['v] to tags of type [bool] *)
type 'v tag_set = { type 'v tag_set = {

View file

@ -27,7 +27,7 @@
]} ]}
@since 0.9 @since 0.9
@since NEXT_RELEASE change of API, the map is last argument to @since 0.16 change of API, the map is last argument to
make piping with [|>] easier. *) make piping with [|>] easier. *)
type 'a injection type 'a injection

View file

@ -89,7 +89,7 @@ end
module ID_MONAD : MONAD with type 'a t = 'a module ID_MONAD : MONAD with type 'a t = 'a
(** The monad that just uses blocking calls as bind (** The monad that just uses blocking calls as bind
@since 0.14 @since 0.14
['a t = 'a] contraint is @since NEXT_RELEASE *) ['a t = 'a] contraint is @since 0.16 *)
module D : module type of MakeDecode(ID_MONAD) module D : module type of MakeDecode(ID_MONAD)
(** Decoder that just blocks when input is not available (** Decoder that just blocks when input is not available

View file

@ -6,7 +6,7 @@
This queue has a limited size. Pushing a value on the queue when it This queue has a limited size. Pushing a value on the queue when it
is full will block. is full will block.
@since NEXT_RELEASE *) @since 0.16 *)
type 'a t type 'a t
(** Safe-thread queue for values of type ['a] *) (** Safe-thread queue for values of type ['a] *)

View file

@ -42,7 +42,7 @@ val update : 'a t -> ('a -> 'a) -> unit
val update_map : 'a t -> ('a -> 'a * 'b) -> 'b val update_map : 'a t -> ('a -> 'a * 'b) -> 'b
(** [update_map l f] computes [x', y = f (get l)], then puts [x'] in [l] (** [update_map l f] computes [x', y = f (get l)], then puts [x'] in [l]
and returns [y] and returns [y]
@since NEXT_RELEASE *) @since 0.16 *)
val mutex : _ t -> Mutex.t val mutex : _ t -> Mutex.t
(** Underlying mutex *) (** Underlying mutex *)
@ -64,24 +64,24 @@ val decr : int t -> unit
val incr_then_get : int t -> int val incr_then_get : int t -> int
(** [incr_then_get x] increments [x], and return its new value (** [incr_then_get x] increments [x], and return its new value
@since NEXT_RELEASE *) @since 0.16 *)
val get_then_incr : int t -> int val get_then_incr : int t -> int
(** [get_then_incr x] increments [x], and return its previous value (** [get_then_incr x] increments [x], and return its previous value
@since NEXT_RELEASE *) @since 0.16 *)
val decr_then_get : int t -> int val decr_then_get : int t -> int
(** [decr_then_get x] decrements [x], and return its new value (** [decr_then_get x] decrements [x], and return its new value
@since NEXT_RELEASE *) @since 0.16 *)
val get_then_decr : int t -> int val get_then_decr : int t -> int
(** [get_then_decr x] decrements [x], and return its previous value (** [get_then_decr x] decrements [x], and return its previous value
@since NEXT_RELEASE *) @since 0.16 *)
val get_then_set : bool t -> bool val get_then_set : bool t -> bool
(** [get_then_set b] sets [b] to [true], and return the old value (** [get_then_set b] sets [b] to [true], and return the old value
@since NEXT_RELEASE *) @since 0.16 *)
val get_then_clear : bool t -> bool val get_then_clear : bool t -> bool
(** [get_then_clear b] sets [b] to [false], and return the old value (** [get_then_clear b] sets [b] to [false], and return the old value
@since NEXT_RELEASE *) @since 0.16 *)

View file

@ -4,7 +4,7 @@
(** {1 Thread Pool, and Futures} (** {1 Thread Pool, and Futures}
Renamed and heavily updated from [CCFuture] Renamed and heavily updated from [CCFuture]
@since NEXT_RELEASE *) @since 0.16 *)
type +'a state = type +'a state =
| Done of 'a | Done of 'a

View file

@ -12,11 +12,11 @@ val spawn : (unit -> _) -> t
val spawn1 : ('a -> _) -> 'a -> t val spawn1 : ('a -> _) -> 'a -> t
(** [spawn1 f x] is like [spawn (fun () -> f x)]. (** [spawn1 f x] is like [spawn (fun () -> f x)].
@since NEXT_RELEASE *) @since 0.16 *)
val spawn2 : ('a -> 'b -> _) -> 'a -> 'b -> t val spawn2 : ('a -> 'b -> _) -> 'a -> 'b -> t
(** [spawn2 f x y] is like [spawn (fun () -> f x y)]. (** [spawn2 f x y] is like [spawn (fun () -> f x y)].
@since NEXT_RELEASE *) @since 0.16 *)
val detach : (unit -> 'a) -> unit val detach : (unit -> 'a) -> unit
(** [detach f] is the same as [ignore (spawn f)] *) (** [detach f] is the same as [ignore (spawn f)] *)

View file

@ -4,7 +4,7 @@
(** {1 Event timer} (** {1 Event timer}
Used to be part of [CCFuture] Used to be part of [CCFuture]
@since NEXT_RELEASE *) @since 0.16 *)
type t type t
(** A scheduler for events. It runs in its own thread. *) (** A scheduler for events. It runs in its own thread. *)

View file

@ -114,25 +114,25 @@ val with_in : ?mode:int -> ?flags:Unix.open_flag list ->
on the input channel. When the function raises or returns, the on the input channel. When the function raises or returns, the
channel is closed. channel is closed.
@param flags opening flags. [Unix.O_RDONLY] is used in any cases @param flags opening flags. [Unix.O_RDONLY] is used in any cases
@since NEXT_RELEASE *) @since 0.16 *)
val with_out : ?mode:int -> ?flags:Unix.open_flag list -> val with_out : ?mode:int -> ?flags:Unix.open_flag list ->
string -> f:(out_channel -> 'a) -> 'a string -> f:(out_channel -> 'a) -> 'a
(** Same as {!with_in} but for an output channel (** Same as {!with_in} but for an output channel
@param flags opening flags (default [[Unix.O_CREAT; Unix.O_TRUNC]]) @param flags opening flags (default [[Unix.O_CREAT; Unix.O_TRUNC]])
[Unix.O_WRONLY] is used in any cases. [Unix.O_WRONLY] is used in any cases.
@since NEXT_RELEASE *) @since 0.16 *)
val with_process_in : string -> f:(in_channel -> 'a) -> 'a val with_process_in : string -> f:(in_channel -> 'a) -> 'a
(** Open a subprocess and obtain a handle to its stdout (** Open a subprocess and obtain a handle to its stdout
@since NEXT_RELEASE *) @since 0.16 *)
val with_process_out : string -> f:(out_channel -> 'a) -> 'a val with_process_out : string -> f:(out_channel -> 'a) -> 'a
(** Open a subprocess and obtain a handle to its stdin (** Open a subprocess and obtain a handle to its stdin
@since NEXT_RELEASE *) @since 0.16 *)
(** Handle to a subprocess. (** Handle to a subprocess.
@since NEXT_RELEASE *) @since 0.16 *)
type process_full = < type process_full = <
stdin: out_channel; stdin: out_channel;
stdout: in_channel; stdout: in_channel;
@ -143,11 +143,11 @@ type process_full = <
val with_process_full : ?env:string array -> string -> f:(process_full -> 'a) -> 'a val with_process_full : ?env:string array -> string -> f:(process_full -> 'a) -> 'a
(** Open a subprocess and obtain a handle to its channels. (** Open a subprocess and obtain a handle to its channels.
@param env environment to pass to the subprocess. @param env environment to pass to the subprocess.
@since NEXT_RELEASE *) @since 0.16 *)
val with_connection : Unix.sockaddr -> f:(in_channel -> out_channel -> 'a) -> 'a val with_connection : Unix.sockaddr -> f:(in_channel -> out_channel -> 'a) -> 'a
(** Wrap {!Unix.open_connection} with a handler (** Wrap {!Unix.open_connection} with a handler
@since NEXT_RELEASE *) @since 0.16 *)
exception ExitServer exception ExitServer
@ -155,7 +155,7 @@ val establish_server : Unix.sockaddr -> f:(in_channel -> out_channel -> _) -> un
(** Listen on the address and calls the handler in a blocking fashion. (** Listen on the address and calls the handler in a blocking fashion.
Using {!Thread} is recommended if handlers might take time. Using {!Thread} is recommended if handlers might take time.
The callback should raise {!ExitServer} to stop the loop. The callback should raise {!ExitServer} to stop the loop.
@since NEXT_RELEASE *) @since 0.16 *)
(** {2 Infix Functions} *) (** {2 Infix Functions} *)