mirror of
https://github.com/c-cube/ocaml-containers.git
synced 2025-12-06 11:15:31 -05:00
version 0.4 backported from stable
This commit is contained in:
parent
f67a3e115e
commit
6ab612c0ac
10 changed files with 51 additions and 41 deletions
10
Makefile
10
Makefile
|
|
@ -88,6 +88,9 @@ push-stable:
|
||||||
git push origin
|
git push origin
|
||||||
git checkout master
|
git checkout master
|
||||||
|
|
||||||
|
clean-generated:
|
||||||
|
rm **/*.{mldylib,mlpack,mllib} myocamlbuild.ml -f
|
||||||
|
|
||||||
run-test: build qtest-build
|
run-test: build qtest-build
|
||||||
./qtest_all.native
|
./qtest_all.native
|
||||||
./run_tests.native
|
./run_tests.native
|
||||||
|
|
@ -97,4 +100,11 @@ test-all: run-test qtest
|
||||||
tags:
|
tags:
|
||||||
otags *.ml *.mli
|
otags *.ml *.mli
|
||||||
|
|
||||||
|
VERSION=$(shell awk '/^Version:/ {print $$2}' _oasis)
|
||||||
|
|
||||||
|
update_next_tag:
|
||||||
|
@echo "update version to $(VERSION)..."
|
||||||
|
sed -i "s/NEXT_VERSION/$(VERSION)/g" **/*.ml **/*.mli
|
||||||
|
sed -i "s/NEXT_RELEASE/$(VERSION)/g" **/*.ml **/*.mli
|
||||||
|
|
||||||
.PHONY: examples push_doc tags qtest
|
.PHONY: examples push_doc tags qtest
|
||||||
|
|
|
||||||
8
_oasis
8
_oasis
|
|
@ -1,6 +1,6 @@
|
||||||
OASISFormat: 0.4
|
OASISFormat: 0.4
|
||||||
Name: containers
|
Name: containers
|
||||||
Version: dev
|
Version: 0.4
|
||||||
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
|
||||||
|
|
@ -192,12 +192,12 @@ Executable test_lwt
|
||||||
BuildDepends: containers,lwt,lwt.unix,oUnit,containers.lwt
|
BuildDepends: containers,lwt,lwt.unix,oUnit,containers.lwt
|
||||||
|
|
||||||
Executable test_threads
|
Executable test_threads
|
||||||
Path: tests/threads/
|
Path: tests/lwt/
|
||||||
Install: false
|
Install: false
|
||||||
CompiledObject: best
|
CompiledObject: best
|
||||||
Build$: flag(tests) && flag(thread)
|
Build$: flag(tests) && flag(thread)
|
||||||
MainIs: test_future.ml
|
MainIs: test_Future.ml
|
||||||
BuildDepends: containers,threads,oUnit,containers.thread
|
BuildDepends: containers,threads,oUnit,containers.lwt
|
||||||
|
|
||||||
Test all
|
Test all
|
||||||
Command: make test-all
|
Command: make test-all
|
||||||
|
|
|
||||||
|
|
@ -72,12 +72,12 @@ module type S = sig
|
||||||
|
|
||||||
val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option
|
val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Like {!find}, but also pass the index to the predicate function.
|
(** Like {!find}, but also pass the index to the predicate function.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option
|
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option
|
||||||
(** [find p x] returns [Some (i,x)] where [x] is the [i]-th element of [l],
|
(** [find p x] returns [Some (i,x)] where [x] is the [i]-th element of [l],
|
||||||
and [p x] holds. Otherwise returns [None]
|
and [p x] holds. Otherwise returns [None]
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val lookup : ?cmp:'a ord -> 'a -> 'a t -> int option
|
val lookup : ?cmp:'a ord -> 'a -> 'a t -> int option
|
||||||
(** Lookup the index of some value in a sorted array.
|
(** Lookup the index of some value in a sorted array.
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
This module was previously named [CCHashtbl], but the name is now used for
|
This module was previously named [CCHashtbl], but the name is now used for
|
||||||
an extension of the standard library's hashtables.
|
an extension of the standard library's hashtables.
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
(** {1 Extension to the standard Hashtbl}
|
(** {1 Extension to the standard Hashtbl}
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
type 'a eq = 'a -> 'a -> bool
|
type 'a eq = 'a -> 'a -> bool
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ val find : ('a -> 'b option) -> 'a t -> 'b option
|
||||||
|
|
||||||
val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option
|
val findi : (int -> 'a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Like {!find}, but also pass the index to the predicate function.
|
(** Like {!find}, but also pass the index to the predicate function.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option
|
val find_idx : ('a -> bool) -> 'a t -> (int * 'a) option
|
||||||
(** [find p x] returns [Some (i,x)] where [x] is the [i]-th element of [l],
|
(** [find p x] returns [Some (i,x)] where [x] is the [i]-th element of [l],
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ val delay : (unit -> 'a t) -> 'a t
|
||||||
small_int >>= fun i -> return (name,i)
|
small_int >>= fun i -> return (name,i)
|
||||||
)
|
)
|
||||||
]}
|
]}
|
||||||
@since NEXT_RELEASE
|
@since 0.4
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val choose : 'a t list -> 'a option t
|
val choose : 'a t list -> 'a option t
|
||||||
|
|
@ -79,7 +79,7 @@ val replicate : int -> 'a t -> 'a list t
|
||||||
|
|
||||||
val list_seq : 'a t list -> 'a list t
|
val list_seq : 'a t list -> 'a list t
|
||||||
(** Build random lists from lists of random generators
|
(** Build random lists from lists of random generators
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val small_int : int t
|
val small_int : int t
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,25 +78,25 @@ val singleton : 'a -> 'a t
|
||||||
|
|
||||||
val doubleton : 'a -> 'a -> 'a t
|
val doubleton : 'a -> 'a -> 'a t
|
||||||
(** Sequence with exactly two elements
|
(** Sequence with exactly two elements
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val cons : 'a -> 'a t -> 'a t
|
val cons : 'a -> 'a t -> 'a t
|
||||||
(** [cons x l] yields [x], then yields from [l].
|
(** [cons x l] yields [x], then yields from [l].
|
||||||
Same as [append (singleton x) l]
|
Same as [append (singleton x) l]
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
|
|
||||||
val snoc : 'a t -> 'a -> 'a t
|
val snoc : 'a t -> 'a -> 'a t
|
||||||
(** Same as {!cons} but yields the element after iterating on [l]
|
(** Same as {!cons} but yields the element after iterating on [l]
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val return : 'a -> 'a t
|
val return : 'a -> 'a t
|
||||||
(** Synonym to {!singleton}
|
(** Synonym to {!singleton}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val pure : 'a -> 'a t
|
val pure : 'a -> 'a t
|
||||||
(** Synonym to {!singleton}
|
(** Synonym to {!singleton}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val repeat : 'a -> 'a t
|
val repeat : 'a -> 'a t
|
||||||
(** Infinite sequence of the same element. You may want to look
|
(** Infinite sequence of the same element. You may want to look
|
||||||
|
|
@ -146,11 +146,11 @@ val exists : ('a -> bool) -> 'a t -> bool
|
||||||
val mem : ?eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool
|
val mem : ?eq:('a -> 'a -> bool) -> 'a -> 'a t -> bool
|
||||||
(** Is the value a member of the sequence?
|
(** Is the value a member of the sequence?
|
||||||
@param eq the equality predicate to use (default [(=)])
|
@param eq the equality predicate to use (default [(=)])
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val find : ('a -> 'b option) -> 'a t -> 'b option
|
val find : ('a -> 'b option) -> 'a t -> 'b option
|
||||||
(** Find the first element on which the function doesn't return [None]
|
(** Find the first element on which the function doesn't return [None]
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val length : 'a t -> int
|
val length : 'a t -> int
|
||||||
(** How long is the sequence? Forces the sequence. *)
|
(** How long is the sequence? Forces the sequence. *)
|
||||||
|
|
@ -179,14 +179,14 @@ val flatMap : ('a -> 'b t) -> 'a t -> 'b t
|
||||||
|
|
||||||
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
|
val flat_map : ('a -> 'b t) -> 'a t -> 'b t
|
||||||
(** Alias to {!flatMap} with a more explicit name
|
(** Alias to {!flatMap} with a more explicit name
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val fmap : ('a -> 'b option) -> 'a t -> 'b t
|
val fmap : ('a -> 'b option) -> 'a t -> 'b t
|
||||||
(** Specialized version of {!flatMap} for options. *)
|
(** Specialized version of {!flatMap} for options. *)
|
||||||
|
|
||||||
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
|
val filter_map : ('a -> 'b option) -> 'a t -> 'b t
|
||||||
(** Alias to {!fmap} with a more explicit name
|
(** Alias to {!fmap} with a more explicit name
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val intersperse : 'a -> 'a t -> 'a t
|
val intersperse : 'a -> 'a t -> 'a t
|
||||||
(** Insert the single element between every element of the sequence *)
|
(** Insert the single element between every element of the sequence *)
|
||||||
|
|
@ -210,7 +210,7 @@ val persistent_lazy : 'a t -> 'a t
|
||||||
is interrupted prematurely ({!take}, etc.) then [s'] will not be
|
is interrupted prematurely ({!take}, etc.) then [s'] will not be
|
||||||
memorized, and the next call to [s'] will traverse [s] again.
|
memorized, and the next call to [s'] will traverse [s] again.
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
(** {2 Misc} *)
|
(** {2 Misc} *)
|
||||||
|
|
||||||
|
|
@ -237,7 +237,7 @@ val product : 'a t -> 'b t -> ('a * 'b) t
|
||||||
|
|
||||||
val product2 : 'a t -> 'b t -> ('a, 'b) t2
|
val product2 : 'a t -> 'b t -> ('a, 'b) t2
|
||||||
(** Binary version of {!product}. Same requirements.
|
(** Binary version of {!product}. Same requirements.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t
|
val join : join_row:('a -> 'b -> 'c option) -> 'a t -> 'b t -> 'c t
|
||||||
(** [join ~join_row a b] combines every element of [a] with every
|
(** [join ~join_row a b] combines every element of [a] with every
|
||||||
|
|
@ -264,12 +264,12 @@ val min : ?lt:('a -> 'a -> bool) -> 'a t -> 'a option
|
||||||
|
|
||||||
val head : 'a t -> 'a option
|
val head : 'a t -> 'a option
|
||||||
(** First element, if any, otherwise [None]
|
(** First element, if any, otherwise [None]
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val head_exn : 'a t -> 'a
|
val head_exn : 'a t -> 'a
|
||||||
(** First element, if any, fails
|
(** First element, if any, fails
|
||||||
@raise Invalid_argument if the sequence is empty
|
@raise Invalid_argument if the sequence is empty
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val take : int -> 'a t -> 'a t
|
val take : int -> 'a t -> 'a t
|
||||||
(** Take at most [n] elements from the sequence. Works on infinite
|
(** Take at most [n] elements from the sequence. Works on infinite
|
||||||
|
|
@ -279,14 +279,14 @@ val take_while : ('a -> bool) -> 'a t -> 'a t
|
||||||
(** Take elements while they satisfy the predicate, then stops iterating.
|
(** Take elements while they satisfy the predicate, then stops iterating.
|
||||||
Will work on an infinite sequence [s] if the predicate is false for at
|
Will work on an infinite sequence [s] if the predicate is false for at
|
||||||
least one element of [s].
|
least one element of [s].
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val drop : int -> 'a t -> 'a t
|
val drop : int -> 'a t -> 'a t
|
||||||
(** Drop the [n] first elements of the sequence. Lazy. *)
|
(** Drop the [n] first elements of the sequence. Lazy. *)
|
||||||
|
|
||||||
val drop_while : ('a -> bool) -> 'a t -> 'a t
|
val drop_while : ('a -> bool) -> 'a t -> 'a t
|
||||||
(** Predicate version of {!drop}
|
(** Predicate version of {!drop}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val rev : 'a t -> 'a t
|
val rev : 'a t -> 'a t
|
||||||
(** Reverse the sequence. O(n) memory and time, needs the
|
(** Reverse the sequence. O(n) memory and time, needs the
|
||||||
|
|
@ -331,12 +331,12 @@ val of_list : 'a list -> 'a t
|
||||||
|
|
||||||
val on_list : ('a t -> 'b t) -> 'a list -> 'b list
|
val on_list : ('a t -> 'b t) -> 'a list -> 'b list
|
||||||
(** [on_list f l] is equivalent to [to_list @@ f @@ of_list l].
|
(** [on_list f l] is equivalent to [to_list @@ f @@ of_list l].
|
||||||
@since NEXT_RELEASE
|
@since 0.4
|
||||||
*)
|
*)
|
||||||
|
|
||||||
val to_opt : 'a t -> 'a option
|
val to_opt : 'a t -> 'a option
|
||||||
(** Alias to {!head}
|
(** Alias to {!head}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val to_array : 'a t -> 'a array
|
val to_array : 'a t -> 'a array
|
||||||
(** Convert to an array. Currently not very efficient because
|
(** Convert to an array. Currently not very efficient because
|
||||||
|
|
@ -355,7 +355,7 @@ val array_slice : 'a array -> int -> int -> 'a t
|
||||||
|
|
||||||
val of_opt : 'a option -> 'a t
|
val of_opt : 'a option -> 'a t
|
||||||
(** Iterate on 0 or 1 values.
|
(** Iterate on 0 or 1 values.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val of_stream : 'a Stream.t -> 'a t
|
val of_stream : 'a Stream.t -> 'a t
|
||||||
(** Sequence of elements of a stream (usable only once) *)
|
(** Sequence of elements of a stream (usable only once) *)
|
||||||
|
|
@ -404,7 +404,7 @@ val to_str : char t -> string
|
||||||
val concat_str : string t -> string
|
val concat_str : string t -> string
|
||||||
(** Concatenate strings together, eagerly.
|
(** Concatenate strings together, eagerly.
|
||||||
Also see {!intersperse} to add a separator.
|
Also see {!intersperse} to add a separator.
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
exception OneShotSequence
|
exception OneShotSequence
|
||||||
(** Raised when the user tries to iterate several times on
|
(** Raised when the user tries to iterate several times on
|
||||||
|
|
@ -457,10 +457,10 @@ module Set : sig
|
||||||
val to_seq : t -> elt sequence
|
val to_seq : t -> elt sequence
|
||||||
|
|
||||||
val to_list : t -> elt list
|
val to_list : t -> elt list
|
||||||
(** @since NEXT_RELEASE *)
|
(** @since 0.4 *)
|
||||||
|
|
||||||
val of_list : elt list -> t
|
val of_list : elt list -> t
|
||||||
(** @since NEXT_RELEASE *)
|
(** @since 0.4 *)
|
||||||
end
|
end
|
||||||
|
|
||||||
(** Create an enriched Set module from the given one *)
|
(** Create an enriched Set module from the given one *)
|
||||||
|
|
@ -481,10 +481,10 @@ module Map : sig
|
||||||
val values : 'a t -> 'a sequence
|
val values : 'a t -> 'a sequence
|
||||||
|
|
||||||
val to_list : 'a t -> (key * 'a) list
|
val to_list : 'a t -> (key * 'a) list
|
||||||
(** @since NEXT_RELEASE *)
|
(** @since 0.4 *)
|
||||||
|
|
||||||
val of_list : (key * 'a) list -> 'a t
|
val of_list : (key * 'a) list -> 'a t
|
||||||
(** @since NEXT_RELEASE *)
|
(** @since 0.4 *)
|
||||||
end
|
end
|
||||||
|
|
||||||
(** Adapt a pre-existing Map module to make it sequence-aware *)
|
(** Adapt a pre-existing Map module to make it sequence-aware *)
|
||||||
|
|
@ -526,19 +526,19 @@ module Infix : sig
|
||||||
|
|
||||||
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
val (>>=) : 'a t -> ('a -> 'b t) -> 'b t
|
||||||
(** Monadic bind (infix version of {!flat_map}
|
(** Monadic bind (infix version of {!flat_map}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
val (>|=) : 'a t -> ('a -> 'b) -> 'b t
|
||||||
(** Infix version of {!map}
|
(** Infix version of {!map}
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
|
val (<*>) : ('a -> 'b) t -> 'a t -> 'b t
|
||||||
(** Applicative operator (product+application)
|
(** Applicative operator (product+application)
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
val (<+>) : 'a t -> 'a t -> 'a t
|
val (<+>) : 'a t -> 'a t -> 'a t
|
||||||
(** Concatenation of sequences
|
(** Concatenation of sequences
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
end
|
end
|
||||||
|
|
||||||
include module type of Infix
|
include module type of Infix
|
||||||
|
|
@ -576,7 +576,7 @@ By chunks of [4096] bytes:
|
||||||
Sequence.IO.(chunks_of ~size:4096 "a" |> write_to "b");;
|
Sequence.IO.(chunks_of ~size:4096 "a" |> write_to "b");;
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
module IO : sig
|
module IO : sig
|
||||||
val lines_of : ?mode:int -> ?flags:open_flag list ->
|
val lines_of : ?mode:int -> ?flags:open_flag list ->
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
(** {1 Simple and efficient S-expression parsing/printing}
|
(** {1 Simple and efficient S-expression parsing/printing}
|
||||||
|
|
||||||
@since NEXT_RELEASE *)
|
@since 0.4 *)
|
||||||
|
|
||||||
type 'a or_error = [ `Ok of 'a | `Error of string ]
|
type 'a or_error = [ `Ok of 'a | `Error of string ]
|
||||||
type 'a sequence = ('a -> unit) -> unit
|
type 'a sequence = ('a -> unit) -> unit
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ This module is meant to be opened if one doesn't want to use both, say,
|
||||||
end
|
end
|
||||||
]}
|
]}
|
||||||
|
|
||||||
@since NEXT_RELEASE
|
@since 0.4
|
||||||
*)
|
*)
|
||||||
|
|
||||||
module Array = struct include Array include CCArray end
|
module Array = struct include Array include CCArray end
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue