mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
prepapre for 1.2
This commit is contained in:
parent
465b5992e8
commit
3ab610ba0e
13 changed files with 86 additions and 50 deletions
|
|
@ -1,5 +1,41 @@
|
|||
= Changelog
|
||||
|
||||
== 1.2
|
||||
|
||||
- make many modules extensions of stdlib (close #109)
|
||||
the modules are: `String List ListLabels Array ArrayLabels Char Random`
|
||||
- add `CCString.{l,r}trim` (close #121)
|
||||
- add `CCInt.floor_div` and `CCInt.rem`
|
||||
- add test and bugfix for `CCBV`
|
||||
- add `CCList.take_drop_while` (close #120)
|
||||
- add `CCstring.equal_caseless` (close #112)
|
||||
- add alias `CCString.split` (close #115)
|
||||
- add `CCFormat.text` (close #111)
|
||||
- add `CCFormat.{newline,substring}`
|
||||
- add `CCList.combine_gen` (close #110)
|
||||
- add module `CCEqual`
|
||||
- add `CCResult.fold_ok` (closes #107)
|
||||
- add `CCFormat.with_color_ksf` for colored printing
|
||||
- add `CCInt.range{,',by}` for iterating on integer ranges
|
||||
- add `CCString.Sub.get`
|
||||
- add `CCResult.add_ctx{,f}` for replacing stack traces
|
||||
- add `CCString.split_on_char`
|
||||
- add `CCArray.{fold_map,scan_left}` (close #101)
|
||||
- add `CCList.scan_left`
|
||||
- add `CCList.{cartesian_product,map_product_l}`
|
||||
- add `CCUnix.with_file_lock` for locking whole files
|
||||
- add `CCFormat.of_chan`
|
||||
- add `CCFormat.flush`
|
||||
- Add `{map_lazy, or_, or_lazy, to_result, to_result_lazy, of_result}` to `CCOpt`
|
||||
|
||||
- annotations in `CCEqual`, for optimization
|
||||
- Add a tail-recursive implementation of `List.combine`
|
||||
- fix too restrictive type in `CCResult`
|
||||
- build unix support by default
|
||||
- bugfix and test for `CCZipper.is_focused` (closes #102)
|
||||
- use boxes in `CCFormat.Dump` for tuples
|
||||
- update header, and use more `(==)` in `CCIntMap`
|
||||
|
||||
== 1.1
|
||||
|
||||
**bugfixes**:
|
||||
|
|
|
|||
2
_oasis
2
_oasis
|
|
@ -1,6 +1,6 @@
|
|||
OASISFormat: 0.4
|
||||
Name: containers
|
||||
Version: 1.1
|
||||
Version: 1.2
|
||||
Homepage: https://github.com/c-cube/ocaml-containers
|
||||
Authors: Simon Cruanes
|
||||
License: BSD-2-clause
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ val fold_while : ('a -> 'b -> 'a * [`Stop | `Continue]) -> 'a -> 'b t -> 'a
|
|||
val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a t -> 'acc * 'b t
|
||||
(** [fold_map f acc a] is a [fold_left]-like function, but it also maps the
|
||||
array to another array.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a t -> 'acc t
|
||||
(** [scan_left f acc a] returns the array
|
||||
[ [|acc; f acc x0; f (f acc a.(0)) a.(1); …|] ]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
|
||||
val iter : ('a -> unit) -> 'a t -> unit
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
(** {1 Equality Combinators} *)
|
||||
|
||||
(** @since NEXT_RELEASE *)
|
||||
(** @since 1.2 *)
|
||||
|
||||
type 'a t = 'a -> 'a -> bool
|
||||
(** Equality function. Must be transitive, symmetric, and reflexive. *)
|
||||
|
|
|
|||
|
|
@ -79,11 +79,11 @@ val to_string : t -> string
|
|||
val of_string_exn : string -> t
|
||||
(** Alias to {!float_of_string}
|
||||
@raise Failure in case of failure
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val of_string : string -> t
|
||||
(** Alias to {!float_of_string}.
|
||||
@deprecated since NEXT_RELEASE, use {!of_string_exn} instead
|
||||
@deprecated since 1.2, use {!of_string_exn} instead
|
||||
@raise Failure in case of failure *)
|
||||
|
||||
val equal_precision : epsilon:t -> t -> t -> bool
|
||||
|
|
|
|||
|
|
@ -25,20 +25,20 @@ val float : float printer
|
|||
|
||||
val newline : unit printer
|
||||
(** Force newline (see {!Format.pp_force_newline})
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val substring : (string * int * int) printer
|
||||
(** Print the substring [(s,i,len)], where [i] is the offset
|
||||
in [s] and [len] the number of bytes in the substring.
|
||||
@raise Invalid_argument if the triple [(s,i,len)] does not
|
||||
describe a proper substring.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val text : string printer
|
||||
(** Print string, but replacing spaces with breaks and newlines
|
||||
with {!newline}.
|
||||
See [pp_print_text] on recent versions of OCaml.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val char : char printer (** @since 0.14 *)
|
||||
val int32 : int32 printer (** @since 0.14 *)
|
||||
|
|
@ -47,7 +47,7 @@ val nativeint : nativeint printer (** @since 0.14 *)
|
|||
|
||||
val flush : unit printer
|
||||
(** Alias to {!Format.pp_print_flush}.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val string_quoted : string printer
|
||||
(** Similar to {!CCString.print}.
|
||||
|
|
@ -204,7 +204,7 @@ val with_color_ksf : f:(string -> 'b) -> string -> ('a, t, unit, 'b) format4 ->
|
|||
{[
|
||||
CCFormat.with_color_ksf "red" ~f:failwith "%a" CCFormat.Dump.(list int) [1;2;3];;
|
||||
]}
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(** {2 IO} *)
|
||||
|
||||
|
|
@ -213,13 +213,13 @@ val to_string : 'a printer -> 'a -> string
|
|||
|
||||
val of_chan : out_channel -> t
|
||||
(** Alias to {!Format.formatter_of_out_channel}
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val with_out_chan : out_channel -> (t -> 'a) -> 'a
|
||||
(** [with_out_chan oc f] turns [oc] into a formatter [fmt], and call [f fmt].
|
||||
Behaves like [f fmt] from then on, but whether the call to [f] fails
|
||||
or returns, [fmt] is flushed before the call terminates.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val stdout : t
|
||||
val stderr : t
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ val pow : t -> t -> t
|
|||
val floor_div : t -> t -> t
|
||||
(** [floor_div a n] is integer division rounding towards negative infinity.
|
||||
It satisfies [a = m * floor_div a n + rem a n].
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val rem : t -> t -> t
|
||||
(** [rem a n] is the remainder of dividing [a] by [n], with the same
|
||||
sign as [n].
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
type 'a printer = Format.formatter -> 'a -> unit
|
||||
type 'a random_gen = Random.State.t -> 'a
|
||||
|
|
@ -67,17 +67,17 @@ val range_by : step:t -> t -> t -> t sequence
|
|||
where the difference between successive elements is [step].
|
||||
use a negative [step] for a decreasing list.
|
||||
@raise Invalid_argument if [step=0]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val range : t -> t -> t sequence
|
||||
(** [range i j] iterates on integers from [i] to [j] included . It works
|
||||
both for decreasing and increasing ranges
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val range' : t -> t -> t sequence
|
||||
(** Same as {!range} but the second bound is excluded.
|
||||
For instance [range' 0 5 = Sequence.of_list [0;1;2;3;4]]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(** {2 Infix Operators}
|
||||
|
||||
|
|
@ -103,11 +103,11 @@ module Infix : sig
|
|||
|
||||
val (--) : t -> t -> t sequence
|
||||
(** Alias to {!range}
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val (--^) : t -> t -> t sequence
|
||||
(** Alias to {!range'}
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
end
|
||||
|
||||
include module type of Infix
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ val fold_map : ('acc -> 'a -> 'acc * 'b) -> 'acc -> 'a list -> 'acc * 'b list
|
|||
val scan_left : ('acc -> 'a -> 'acc) -> 'acc -> 'a list -> 'acc list
|
||||
(** [scan_left f acc l] returns the list [[acc; f acc x0; f (f acc x0) x1; …]]
|
||||
where [x0], [x1], etc. are the elements of [l]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
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].
|
||||
|
|
@ -83,14 +83,14 @@ val init : int -> (int -> 'a) -> 'a t
|
|||
val combine : 'a list -> 'b list -> ('a * 'b) list
|
||||
(** Similar to {!List.combine} but tail-recursive.
|
||||
@raise Invalid_argument if the lists have distinct lengths.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val combine_gen : 'a list -> 'b list -> ('a * 'b) gen
|
||||
(** Lazy version of {!combine}.
|
||||
Unlike {!combine}, it does not fail if the lists have different
|
||||
lengths;
|
||||
instead, the output has as many pairs as the smallest input list.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val compare : ('a -> 'a -> int) -> 'a t -> 'a t -> int
|
||||
|
||||
|
|
@ -119,14 +119,14 @@ val cartesian_product : 'a t t -> 'a t t
|
|||
[[1;3;4;5;6];[2;3;4;5;6]];;
|
||||
]}
|
||||
invariant: [cartesian_product l = map_product id l].
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val map_product_l : ('a -> 'b list) -> 'a list -> 'b list list
|
||||
(** [map_product_l f l] maps each element of [l] to a list of
|
||||
objects of type ['b] using [f].
|
||||
We obtain [[l1;l2;…;ln]] where [length l=n] and [li : 'b list].
|
||||
Then, it returns all the ways of picking exactly one element per [li].
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val diagonal : 'a t -> ('a * 'a) t
|
||||
(** All pairs of distinct positions of the list. [list_diagonal l] will
|
||||
|
|
@ -201,7 +201,7 @@ val drop_while : ('a -> bool) -> 'a t -> 'a t
|
|||
|
||||
val take_drop_while : ('a -> bool) -> 'a t -> 'a t * 'a t
|
||||
(** [take_drop_while p l = take_while p l, drop_while p l]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val last : int -> 'a t -> 'a t
|
||||
(** [last n l] takes the last [n] elements of [l] (or less if
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ val map_or : default:'b -> ('a -> 'b) -> 'a t -> 'b
|
|||
|
||||
val map_lazy : (unit -> 'b) -> ('a -> 'b) -> 'a t -> 'b
|
||||
(** [map_lazy default_fn f o] if [f o] if [o = Some x], [default_fn ()] otherwise
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val is_some : _ t -> bool
|
||||
|
||||
|
|
@ -100,11 +100,11 @@ val (<$>) : ('a -> 'b) -> 'a t -> 'b t
|
|||
|
||||
val or_ : else_:('a t) -> 'a t -> 'a t
|
||||
(** [or_ ~else_ a] is [a] if [a] is [Some _], [else_] otherwise
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val or_lazy : else_:(unit -> 'a t) -> 'a t -> 'a t
|
||||
(** [or_lazy else_ a] is [a] if [a] is [Some _], [else_ ()] otherwise
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val (<+>) : 'a t -> 'a t -> 'a t
|
||||
(** [a <+> b] is [a] if [a] is [Some _], [b] otherwise *)
|
||||
|
|
@ -131,13 +131,13 @@ val of_list : 'a list -> 'a t
|
|||
(** Head of list, or [None] *)
|
||||
|
||||
val to_result : 'e -> 'a t -> ('a, 'e) Result.result
|
||||
(** @since NEXT_RELEASE *)
|
||||
(** @since 1.2 *)
|
||||
|
||||
val to_result_lazy : (unit -> 'e) -> 'a t -> ('a, 'e) Result.result
|
||||
(** @since NEXT_RELEASE *)
|
||||
(** @since 1.2 *)
|
||||
|
||||
val of_result : ('a, _) Result.result -> 'a t
|
||||
(** @since NEXT_RELEASE *)
|
||||
(** @since 1.2 *)
|
||||
|
||||
type 'a sequence = ('a -> unit) -> unit
|
||||
type 'a gen = unit -> 'a option
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ val add_ctx : string -> ('a, string) t -> ('a, string) t
|
|||
(** [add_ctx msg] leaves [Ok x] untouched, but transforms
|
||||
[Error s] into [Error s'] where [s'] contains the additional
|
||||
context given by [msg]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val add_ctxf : ('a, Format.formatter, unit, ('b, string) t -> ('b, string) t) format4 -> 'a
|
||||
(** [add_ctxf format_message] is similar to {!add_ctx} but with
|
||||
|
|
@ -54,7 +54,7 @@ val add_ctxf : ('a, Format.formatter, unit, ('b, string) t -> ('b, string) t) fo
|
|||
Example: {[
|
||||
add_ctxf "message(number %d, foo: %B)" 42 true (Error "error)"
|
||||
]}
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val map : ('a -> 'b) -> ('a, 'err) t -> ('b, 'err) t
|
||||
(** Map on success *)
|
||||
|
|
@ -104,7 +104,7 @@ val fold : ok:('a -> 'b) -> error:('err -> 'b) -> ('a, 'err) t -> 'b
|
|||
val fold_ok : ('a -> 'b -> 'a) -> 'a -> ('b, _) t -> 'a
|
||||
(** [fold_ok f acc r] will compute [f acc x] if [r=Ok x],
|
||||
and return [acc] otherwise, as if the result were a mere option.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val is_ok : ('a, 'err) t -> bool
|
||||
(** Return true if Ok
|
||||
|
|
|
|||
|
|
@ -353,11 +353,11 @@ include S with type t := string
|
|||
|
||||
val ltrim : t -> t
|
||||
(** trim space on the left (see {!String.trim} for more details)
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val rtrim : t -> t
|
||||
(** trim space on the right (see {!String.trim} for more details)
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(*$= & ~printer:id
|
||||
"abc " (ltrim " abc ")
|
||||
|
|
@ -428,7 +428,7 @@ val lowercase_ascii : string -> string
|
|||
|
||||
val equal_caseless : string -> string -> bool
|
||||
(** Comparison without respect to {b ascii} lowercase.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(*$T
|
||||
equal_caseless "foo" "FoO"
|
||||
|
|
@ -540,7 +540,7 @@ end
|
|||
|
||||
val split_on_char : char -> string -> string list
|
||||
(** Split the string along the given char
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(*$= & ~printer:Q.Print.(list string)
|
||||
["a"; "few"; "words"; "from"; "our"; "sponsors"] \
|
||||
|
|
@ -555,7 +555,7 @@ val split_on_char : char -> string -> string list
|
|||
|
||||
val split : by:string -> string -> string list
|
||||
(** Alias to {!Split.list_cpy}
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(** {2 Utils} *)
|
||||
|
||||
|
|
@ -635,7 +635,7 @@ module Sub : sig
|
|||
val get : t -> int -> char
|
||||
(** [get s i] gets the [i]-th element, or fails
|
||||
@raise Invalid_argument if the index is not within [0... length -1]
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
include S with type t := t
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
(** {2 Imperative Bitvectors}
|
||||
|
||||
{b BREAKING CHANGES} since NEXT_RELEASE:
|
||||
{b BREAKING CHANGES} since 1.2:
|
||||
size is now stored along with the bitvector. Some functions have
|
||||
a new signature.
|
||||
|
||||
|
|
@ -30,13 +30,13 @@ val cardinal : t -> int
|
|||
val length : t -> int
|
||||
(** Size of underlying bitvector.
|
||||
This is not related to the underlying implementation.
|
||||
Changed at NEXT_RELEASE
|
||||
Changed at 1.2
|
||||
*)
|
||||
|
||||
val capacity : t -> int
|
||||
(** The number of bits this bitvector can store without resizing.
|
||||
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val resize : t -> int -> unit
|
||||
(** Resize the BV so that it has the specified length. This can grow or shrink
|
||||
|
|
@ -83,12 +83,12 @@ val of_list : int list -> t
|
|||
|
||||
val first : t -> int option
|
||||
(** First set bit, or return None.
|
||||
changed type at NEXT_RELEASE *)
|
||||
changed type at 1.2 *)
|
||||
|
||||
val first_exn : t -> int
|
||||
(** First set bit, or
|
||||
@raise Not_found if all bits are 0
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val filter : t -> (int -> bool) -> unit
|
||||
(** [filter bv p] only keeps the true bits of [bv] whose [index]
|
||||
|
|
@ -97,7 +97,7 @@ val filter : t -> (int -> bool) -> unit
|
|||
val negate_self : t -> unit
|
||||
(** [negate_self t] flips all of the bits in [t].
|
||||
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val negate : t -> t
|
||||
(** [negate t] returns a copy of [t] with all of the bits flipped. *)
|
||||
|
|
@ -121,12 +121,12 @@ val inter : t -> t -> t
|
|||
val diff_into : into:t -> t -> unit
|
||||
(** [diff ~into t] Modify [into] with only the bits set but not in [t].
|
||||
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val diff : t -> t -> t
|
||||
(** [diff t1 t2] Return those bits found [t1] but not in [t2].
|
||||
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
val select : t -> 'a array -> 'a list
|
||||
(** [select arr bv] selects the elements of [arr] whose index
|
||||
|
|
|
|||
|
|
@ -168,7 +168,7 @@ val with_file_lock : kind:[`Read|`Write] -> string -> (unit -> 'a) -> 'a
|
|||
re-raised after the file is unlocked.
|
||||
|
||||
@param kind specifies whether the lock is read-only or read-write.
|
||||
@since NEXT_RELEASE *)
|
||||
@since 1.2 *)
|
||||
|
||||
(** {2 Infix Functions} *)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue