From 011e8ecb767df6fa9efa7d49ad1aa2a8f526c686 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Thu, 21 Dec 2017 15:01:43 +0100 Subject: [PATCH 01/10] add test dependencies --- opam | 2 ++ 1 file changed, 2 insertions(+) diff --git a/opam b/opam index f3bb2b5..36beb29 100644 --- a/opam +++ b/opam @@ -28,6 +28,8 @@ depends: [ "ocamlfind" "base-bytes" "ocamlbuild" {build} + "qcheck" {test} + "qtest" {test} ] tags: [ "sequence" "iterator" "iter" "fold" ] homepage: "https://github.com/c-cube/sequence/" From dbf977edaa1be503ecc54e0bc9f2ae02ea6f5be3 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 24 Dec 2017 17:01:01 +0100 Subject: [PATCH 02/10] add travis --- .travis.yml | 35 +++++++++++++++++++++++++++++++++++ README.adoc | 2 ++ 2 files changed, 37 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..c73cd77 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,35 @@ +language: c +env: + - OCAML_VERSION=4.01.0 + - OCAML_VERSION=4.02.3 + - OCAML_VERSION=4.04.2 + - OCAML_VERSION=4.05.0 + - OCAML_VERSION=4.05.0+flambda + - OCAML_VERSION=4.06.0 +addons: + apt: + sources: + - avsm + packages: + - opam +# Caching may take a lot of space with so many ocaml versions +#cache: +# directories: +# - $HOME/.opam +before_install: + # Some opam boilerplate + - export OPAMYES=1 + - export OPAMVERBOSE=1 + - opam init + - opam switch ${OCAML_VERSION} + - eval `opam config env` +install: + # Install dependencies + - opam pin add --no-action sequence . + - opam install oasis + - opam install --deps-only sequence +script: + - make build + - opam install qcheck qtest + - ./configure --enable-tests + - make test diff --git a/README.adoc b/README.adoc index 719d098..60ce610 100644 --- a/README.adoc +++ b/README.adoc @@ -13,6 +13,8 @@ way of iterating on a finite number of values, only allocating (most of the time one intermediate closure to do so. For instance, iterating on keys, or values, of a `Hashtbl.t`, without creating a list. +image::https://travis-ci.org/c-cube/sequence.svg?branch=master[alt="Build Status", link="https://travis-ci.org/c-cube/sequence"] + toc::[] == Documentation From 8e7d2bf77e631a094d1533a9b2e6eaeff6f1baa4 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 24 Dec 2017 17:25:59 +0100 Subject: [PATCH 03/10] avoid using too recent a function in tests --- src/Sequence.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Sequence.ml b/src/Sequence.ml index aa0e350..c60eff9 100644 --- a/src/Sequence.ml +++ b/src/Sequence.ml @@ -1106,8 +1106,9 @@ let to_buffer seq buf = (*$R let b = Buffer.create 4 in + let upp = function 'a'..'z' as c -> Char.chr (Char.code c - Char.code 'a' + Char.code 'A') | c -> c in "hello world" - |> of_str |> rev |> map Char.uppercase_ascii + |> of_str |> rev |> map upp |> (fun seq -> to_buffer seq b); OUnit.assert_equal "DLROW OLLEH" (Buffer.contents b); *) From 204b47cb3f2b3da12fb21b09636ebf860d1ca235 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 14 Jan 2018 16:14:10 -0600 Subject: [PATCH 04/10] remove type `t2`, breaking compat --- src/Sequence.ml | 45 ++++++------------------------------------ src/Sequence.mli | 41 +++++++++----------------------------- src/SequenceLabels.mli | 41 +++++++++----------------------------- 3 files changed, 24 insertions(+), 103 deletions(-) diff --git a/src/Sequence.ml b/src/Sequence.ml index c60eff9..9a05f36 100644 --- a/src/Sequence.ml +++ b/src/Sequence.ml @@ -8,9 +8,6 @@ type 'a t = ('a -> unit) -> unit type 'a sequence = 'a t -type (+'a, +'b) t2 = ('a -> 'b -> unit) -> unit -(** Sequence of pairs of values of type ['a] and ['b]. *) - (*$inject let pp_ilist = Q.Print.(list int) *) @@ -515,9 +512,6 @@ let product outer inner k = "c",0; "c", 1; "c", 2;] s *) -let product2 outer inner k = - outer (fun x -> inner (fun y -> k x y)) - let rec diagonal_l l yield = match l with | [] -> () | x::tail -> @@ -946,36 +940,21 @@ let is_empty seq = (** {2 Transform a sequence} *) -let empty2 _ = () - -let is_empty2 seq2 = - try ignore (seq2 (fun _ _ -> raise ExitIsEmpty)); true - with ExitIsEmpty -> false - -let length2 seq2 = - let r = ref 0 in - seq2 (fun _ _ -> incr r); - !r - -let zip seq2 k = seq2 (fun x y -> k (x,y)) - -let unzip seq k = seq (fun (x,y) -> k x y) - let zip_i seq k = let r = ref 0 in - seq (fun x -> let n = !r in incr r; k n x) + seq (fun x -> let n = !r in incr r; k (n, x)) let fold2 f acc seq2 = let acc = ref acc in - seq2 (fun x y -> acc := f !acc x y); + seq2 (fun (x,y) -> acc := f !acc x y); !acc -let iter2 f seq2 = seq2 f +let iter2 f seq2 = seq2 (fun (x,y) -> f x y) -let map2 f seq2 k = seq2 (fun x y -> k (f x y)) +let map2 f seq2 k = seq2 (fun (x,y) -> k (f x y)) let map2_2 f g seq2 k = - seq2 (fun x y -> k (f x y) (g x y)) + seq2 (fun (x,y) -> k (f x y, g x y)) (** {2 Basic data structures converters} *) @@ -1016,11 +995,6 @@ let of_array_i a k = k (i, Array.unsafe_get a i) done -let of_array2 a k = - for i = 0 to Array.length a - 1 do - k i (Array.unsafe_get a i) - done - let array_slice a i j k = assert (i >= 0 && j < Array.length a); for idx = i to j do @@ -1047,7 +1021,7 @@ let hashtbl_add h seq = (*$R let h = (1 -- 5) |> zip_i - |> to_hashtbl2 in + |> to_hashtbl in (0 -- 4) |> iter (fun i -> OUnit.assert_equal (i+1) (Hashtbl.find h i)); OUnit.assert_equal [0;1;2;3;4] (hashtbl_keys h |> sort ?cmp:None |> to_list); @@ -1061,15 +1035,8 @@ let to_hashtbl seq = hashtbl_replace h seq; h -let to_hashtbl2 seq2 = - let h = Hashtbl.create 3 in - seq2 (fun k v -> Hashtbl.replace h k v); - h - let of_hashtbl h k = Hashtbl.iter (fun a b -> k (a, b)) h -let of_hashtbl2 h k = Hashtbl.iter k h - let hashtbl_keys h k = Hashtbl.iter (fun a _ -> k a) h let hashtbl_values h k = Hashtbl.iter (fun _ b -> k b) h diff --git a/src/Sequence.mli b/src/Sequence.mli index 0d6fb79..f9000b9 100644 --- a/src/Sequence.mli +++ b/src/Sequence.mli @@ -36,8 +36,8 @@ type +'a t = ('a -> unit) -> unit type +'a sequence = 'a t -type (+'a, +'b) t2 = ('a -> 'b -> unit) -> unit -(** Sequence of pairs of values of type ['a] and ['b]. *) +(** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit] + has been removed and subsumed by [('a * 'b) t] @since NEXT_RELEASE *) type 'a equal = 'a -> 'a -> bool type 'a hash = 'a -> int @@ -299,10 +299,6 @@ val diagonal : 'a t -> ('a * 'a) t Iterates only once on the sequence, which must be finite. @since 0.9 *) -val product2 : 'a t -> 'b t -> ('a, 'b) t2 -(** Binary version of {!product}. Same requirements. - @since 0.5 *) - 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 element of [b] using [join_row]. If [join_row] returns None, then @@ -470,28 +466,17 @@ val rev : 'a t -> 'a t sequence to be finite. The result is persistent and does not depend on the input being repeatable. *) -(** {2 Binary sequences} *) +val zip_i : 'a t -> (int * 'a) t +(** Zip elements of the sequence with their index in the sequence. + Changed type @since NEXT_RELEASE to just give a sequence of pairs *) -val empty2 : ('a, 'b) t2 +val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a * 'b) t -> 'c -val is_empty2 : (_, _) t2 -> bool +val iter2 : ('a -> 'b -> unit) -> ('a * 'b) t -> unit -val length2 : (_, _) t2 -> int +val map2 : ('a -> 'b -> 'c) -> ('a * 'b) t -> 'c t -val zip : ('a, 'b) t2 -> ('a * 'b) t - -val unzip : ('a * 'b) t -> ('a, 'b) t2 - -val zip_i : 'a t -> (int, 'a) t2 -(** Zip elements of the sequence with their index in the sequence *) - -val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a, 'b) t2 -> 'c - -val iter2 : ('a -> 'b -> unit) -> ('a, 'b) t2 -> unit - -val map2 : ('a -> 'b -> 'c) -> ('a, 'b) t2 -> 'c t - -val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a, 'b) t2 -> ('c, 'd) t2 +val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t (** [map2_2 f g seq2] maps each [x, y] of seq2 into [f x y, g x y] *) (** {2 Basic data structures converters} *) @@ -528,8 +513,6 @@ val of_array : 'a array -> 'a t val of_array_i : 'a array -> (int * 'a) t (** Elements of the array, with their index *) -val of_array2 : 'a array -> (int, 'a) t2 - val array_slice : 'a array -> int -> int -> 'a t (** [array_slice a i j] Sequence of elements whose indexes range from [i] to [j] *) @@ -567,15 +550,9 @@ val hashtbl_replace : ('a, 'b) Hashtbl.t -> ('a * 'b) t -> unit val to_hashtbl : ('a * 'b) t -> ('a, 'b) Hashtbl.t (** Build a hashtable from a sequence of key/value pairs *) -val to_hashtbl2 : ('a, 'b) t2 -> ('a, 'b) Hashtbl.t -(** Build a hashtable from a sequence of key/value pairs *) - val of_hashtbl : ('a, 'b) Hashtbl.t -> ('a * 'b) t (** Sequence of key/value pairs from the hashtable *) -val of_hashtbl2 : ('a, 'b) Hashtbl.t -> ('a, 'b) t2 -(** Sequence of key/value pairs from the hashtable *) - val hashtbl_keys : ('a, 'b) Hashtbl.t -> 'a t val hashtbl_values : ('a, 'b) Hashtbl.t -> 'b t diff --git a/src/SequenceLabels.mli b/src/SequenceLabels.mli index 5b582e2..a928522 100644 --- a/src/SequenceLabels.mli +++ b/src/SequenceLabels.mli @@ -14,8 +14,8 @@ type +'a t = ('a -> unit) -> unit type +'a sequence = 'a t -type (+'a, +'b) t2 = ('a -> 'b -> unit) -> unit -(** Sequence of pairs of values of type ['a] and ['b]. *) +(** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit] + has been removed and subsumed by [('a * 'b) t] @since NEXT_RELEASE *) type 'a equal = 'a -> 'a -> bool type 'a hash = 'a -> int @@ -271,10 +271,6 @@ val diagonal : 'a t -> ('a * 'a) t Iterates only once on the sequence, which must be finite. @since 0.9 *) -val product2 : 'a t -> 'b t -> ('a, 'b) t2 -(** Binary version of {!product}. Same requirements. - @since 0.5 *) - 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 element of [b] using [join_row]. If [join_row] returns None, then @@ -442,28 +438,17 @@ val rev : 'a t -> 'a t sequence to be finite. The result is persistent and does not depend on the input being repeatable. *) -(** {2 Binary sequences} *) +val zip_i : 'a t -> (int * 'a) t +(** Zip elements of the sequence with their index in the sequence. + Changed type @since NEXT_RELEASE to just give a sequence of pairs *) -val empty2 : ('a, 'b) t2 +val fold2 : f:('c -> 'a -> 'b -> 'c) -> init:'c -> ('a * 'b) t -> 'c -val is_empty2 : (_, _) t2 -> bool +val iter2 : f:('a -> 'b -> unit) -> ('a * 'b) t -> unit -val length2 : (_, _) t2 -> int +val map2 : f:('a -> 'b -> 'c) -> ('a * 'b) t -> 'c t -val zip : ('a, 'b) t2 -> ('a * 'b) t - -val unzip : ('a * 'b) t -> ('a, 'b) t2 - -val zip_i : 'a t -> (int, 'a) t2 -(** Zip elements of the sequence with their index in the sequence *) - -val fold2 : f:('c -> 'a -> 'b -> 'c) -> init:'c -> ('a, 'b) t2 -> 'c - -val iter2 : f:('a -> 'b -> unit) -> ('a, 'b) t2 -> unit - -val map2 : f:('a -> 'b -> 'c) -> ('a, 'b) t2 -> 'c t - -val map2_2 : ('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a, 'b) t2 -> ('c, 'd) t2 +val map2_2 : f:('a -> 'b -> 'c) -> ('a -> 'b -> 'd) -> ('a * 'b) t -> ('c * 'd) t (** [map2_2 f g seq2] maps each [x, y] of seq2 into [f x y, g x y] *) (** {2 Basic data structures converters} *) @@ -500,8 +485,6 @@ val of_array : 'a array -> 'a t val of_array_i : 'a array -> (int * 'a) t (** Elements of the array, with their index *) -val of_array2 : 'a array -> (int, 'a) t2 - val array_slice : 'a array -> int -> int -> 'a t (** [array_slice a i j] Sequence of elements whose indexes range from [i] to [j] *) @@ -539,15 +522,9 @@ val hashtbl_replace : ('a, 'b) Hashtbl.t -> ('a * 'b) t -> unit val to_hashtbl : ('a * 'b) t -> ('a, 'b) Hashtbl.t (** Build a hashtable from a sequence of key/value pairs *) -val to_hashtbl2 : ('a, 'b) t2 -> ('a, 'b) Hashtbl.t -(** Build a hashtable from a sequence of key/value pairs *) - val of_hashtbl : ('a, 'b) Hashtbl.t -> ('a * 'b) t (** Sequence of key/value pairs from the hashtable *) -val of_hashtbl2 : ('a, 'b) Hashtbl.t -> ('a, 'b) t2 -(** Sequence of key/value pairs from the hashtable *) - val hashtbl_keys : ('a, 'b) Hashtbl.t -> 'a t val hashtbl_values : ('a, 'b) Hashtbl.t -> 'b t From 6b5f4cf40eeeb59098a02e103817474eaa15f83b Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 14 Jan 2018 16:18:18 -0600 Subject: [PATCH 05/10] add `filter_count` --- src/Sequence.ml | 11 +++++++++++ src/Sequence.mli | 4 ++++ src/SequenceLabels.mli | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/src/Sequence.ml b/src/Sequence.ml index 9a05f36..1ed134b 100644 --- a/src/Sequence.ml +++ b/src/Sequence.ml @@ -207,6 +207,17 @@ let filter_mapi f seq k = | None -> () | Some y -> k y) +let filter_count f seq = + let i = ref 0 in + seq (fun x -> if f x then incr i); + !i + +(*$Q + Q.(list int) (fun l -> \ + let seq = of_list l and f x = x mod 2 = 0 in \ + filter_count f seq = (filter f seq |> length)) +*) + let intersperse elem seq k = let first = ref true in seq (fun x -> (if !first then first := false else k elem); k x) diff --git a/src/Sequence.mli b/src/Sequence.mli index f9000b9..5a09e41 100644 --- a/src/Sequence.mli +++ b/src/Sequence.mli @@ -224,6 +224,10 @@ val filter_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b t (** Map with indices, and only keep non-[None] elements @since 0.11 *) +val filter_count : ('a -> bool) -> 'a t -> int +(** Count how many elements satisfy the given predicate + @since NEXT_RELEASE *) + val intersperse : 'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *) diff --git a/src/SequenceLabels.mli b/src/SequenceLabels.mli index a928522..31af7d1 100644 --- a/src/SequenceLabels.mli +++ b/src/SequenceLabels.mli @@ -197,6 +197,10 @@ val seq_list_map : f:('a -> 'b t) -> 'a list -> 'b list t then calls {!seq_list} @since 0.11 *) +val filter_count : f:('a -> bool) -> 'a t -> int +(** Count how many elements satisfy the given predicate + @since NEXT_RELEASE *) + val intersperse : x:'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *) From d860c832e0214fb7014a54c56beee2f0c5f86076 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 14 Jan 2018 16:27:37 -0600 Subject: [PATCH 06/10] add some functions using `result` --- .merlin | 6 ++---- _oasis | 2 +- opam | 1 + src/Sequence.ml | 18 ++++++++++++++++++ src/Sequence.mli | 13 +++++++++++++ src/SequenceLabels.mli | 13 +++++++++++++ 6 files changed, 48 insertions(+), 5 deletions(-) diff --git a/.merlin b/.merlin index 68e740a..4648f95 100644 --- a/.merlin +++ b/.merlin @@ -4,7 +4,5 @@ S tests/ B _build/src B _build/tests/ B _build/bench/ -PKG oUnit qcheck -PKG benchmark -FLG -safe-string -FLG -w+a-4-44-48-60@8 +PKG oUnit qcheck result benchmark +FLG -safe-string -w+a-4-44-48-60@8 diff --git a/_oasis b/_oasis index d0a407a..ce3ec32 100644 --- a/_oasis +++ b/_oasis @@ -30,7 +30,7 @@ Flag bigarray Library "sequence" Path: src/ Modules: Sequence, SequenceLabels - BuildDepends: bytes + BuildDepends: bytes, result Library "invert" Path: src/invert diff --git a/opam b/opam index 36beb29..37ede30 100644 --- a/opam +++ b/opam @@ -27,6 +27,7 @@ remove: [ depends: [ "ocamlfind" "base-bytes" + "result" "ocamlbuild" {build} "qcheck" {test} "qtest" {test} diff --git a/src/Sequence.ml b/src/Sequence.ml index 1ed134b..2def117 100644 --- a/src/Sequence.ml +++ b/src/Sequence.ml @@ -230,6 +230,24 @@ let intersperse elem seq k = |> OUnit.assert_equal [1;0;2;0;3;0;4;0;5;0] *) +let keep_some seq k = + seq + (function + | Some x -> k x + | None -> ()) + +let keep_ok seq k = + seq + (function + | Result.Ok x -> k x + | Result.Error _ -> ()) + +let keep_error seq k = + seq + (function + | Result.Error x -> k x + | Result.Ok _ -> ()) + (** Mutable unrolled list to serve as intermediate storage *) module MList = struct type 'a node = diff --git a/src/Sequence.mli b/src/Sequence.mli index 5a09e41..b6a2fdb 100644 --- a/src/Sequence.mli +++ b/src/Sequence.mli @@ -231,6 +231,19 @@ val filter_count : ('a -> bool) -> 'a t -> int val intersperse : 'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *) +val keep_some : 'a option t -> 'a t +(** [filter_some l] retains only elements of the form [Some x]. + Same as [filter_map (fun x->x)] + @since NEXT_RELEASE *) + +val keep_ok : ('a, _) Result.result t -> 'a t +(** [keep_ok l] retains only elements of the form [Ok x]. + @since NEXT_RELEASE *) + +val keep_error : (_, 'e) Result.result t -> 'e t +(** [keep_error l] retains only elements of the form [Error x]. + @since NEXT_RELEASE *) + (** {2 Caching} *) val persistent : 'a t -> 'a t diff --git a/src/SequenceLabels.mli b/src/SequenceLabels.mli index 31af7d1..809c054 100644 --- a/src/SequenceLabels.mli +++ b/src/SequenceLabels.mli @@ -204,6 +204,19 @@ val filter_count : f:('a -> bool) -> 'a t -> int val intersperse : x:'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *) +val keep_some : 'a option t -> 'a t +(** [filter_some l] retains only elements of the form [Some x]. + Same as [filter_map (fun x->x)] + @since NEXT_RELEASE *) + +val keep_ok : ('a, _) Result.result t -> 'a t +(** [keep_ok l] retains only elements of the form [Ok x]. + @since NEXT_RELEASE *) + +val keep_error : (_, 'e) Result.result t -> 'e t +(** [keep_error l] retains only elements of the form [Error x]. + @since NEXT_RELEASE *) + (** {2 Caching} *) val persistent : 'a t -> 'a t From 2a989a2cf31408d60107bd89f04c196a142811cf Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 17 Dec 2017 15:06:38 +0100 Subject: [PATCH 07/10] move to jbuilder --- .gitignore | 5 +- META | 11 - Makefile | 75 +----- _oasis | 103 ------- _tags | 35 --- bench/jbuild | 8 + examples/jbuild | 8 + myocamlbuild.ml | 609 ------------------------------------------ qtest/Makefile | 15 ++ qtest/jbuild | 21 ++ opam => sequence.opam | 17 +- setup.ml | 37 --- src/bigarray/jbuild | 11 + src/invert/jbuild | 12 + src/jbuild | 11 + 15 files changed, 108 insertions(+), 870 deletions(-) delete mode 100644 META delete mode 100644 _oasis delete mode 100644 _tags create mode 100644 bench/jbuild create mode 100644 examples/jbuild delete mode 100644 myocamlbuild.ml create mode 100644 qtest/Makefile create mode 100644 qtest/jbuild rename opam => sequence.opam (67%) delete mode 100644 setup.ml create mode 100644 src/bigarray/jbuild create mode 100644 src/invert/jbuild create mode 100644 src/jbuild diff --git a/.gitignore b/.gitignore index 96cadb3..b6f35bb 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,5 @@ _build *.docdir *.html man/ -sequence.install -setup.log -setup.data +*.install +.merlin diff --git a/META b/META deleted file mode 100644 index e2f9a7d..0000000 --- a/META +++ /dev/null @@ -1,11 +0,0 @@ -# OASIS_START -# DO NOT EDIT (digest: 1e28d93f3671e8db9acf63b73cdbca82) -version = "0.4.1" -description = "Simple sequence (iterator) datatype and combinators" -archive(byte) = "sequence.cma" -archive(byte, plugin) = "sequence.cma" -archive(native) = "sequence.cmxa" -archive(native, plugin) = "sequence.cmxs" -exists_if = "sequence.cma" -# OASIS_STOP - diff --git a/Makefile b/Makefile index 03e60f1..996dd37 100644 --- a/Makefile +++ b/Makefile @@ -1,79 +1,30 @@ -# OASIS_START -# DO NOT EDIT (digest: a3c674b4239234cbbe53afe090018954) -SETUP = ocaml setup.ml +all: build test -build: setup.data - $(SETUP) -build $(BUILDFLAGS) +build: + jbuilder build @install -doc: setup.data build - $(SETUP) -doc $(DOCFLAGS) - -test: setup.data build - $(SETUP) -test $(TESTFLAGS) - -all: - $(SETUP) -all $(ALLFLAGS) - -install: setup.data - $(SETUP) -install $(INSTALLFLAGS) - -uninstall: setup.data - $(SETUP) -uninstall $(UNINSTALLFLAGS) - -reinstall: setup.data - $(SETUP) -reinstall $(REINSTALLFLAGS) +test: + jbuilder runtest clean: - $(SETUP) -clean $(CLEANFLAGS) + jbuilder clean -distclean: - $(SETUP) -distclean $(DISTCLEANFLAGS) +doc: + jbuilder build @doc -setup.data: - $(SETUP) -configure $(CONFIGUREFLAGS) +BENCH_TARGETS=bench_persistent_read.exe bench_persistent.exe -configure: - $(SETUP) -configure $(CONFIGUREFLAGS) - -.PHONY: build doc test all install uninstall reinstall clean distclean configure - -# OASIS_STOP - -QTEST_PREAMBLE='' -DONTTEST=src/sequenceLabels.ml -QTESTABLE=$(filter-out $(DONTTEST), \ - $(wildcard src/*.ml) \ - $(wildcard src/*.mli) \ - ) - -qtest-clean: - @rm -rf qtest/ - -qtest-gen: - @mkdir -p qtest - @if which qtest > /dev/null ; then \ - qtest extract --preamble $(QTEST_PREAMBLE) \ - -o qtest/run_qtest.ml \ - $(QTESTABLE) 2> /dev/null ; \ - else touch qtest/run_qtest.ml ; \ - fi +benchs: + jbuilder build $(addprefix bench/, $(BENCH_TARGETS)) examples: - ocamlbuild examples/test_sexpr.native + jbuilder build examples/test_sexpr.exe push_doc: all doc scp -r sequence.docdir/* cedeela.fr:~/simon/root/software/sequence/ -push_stable: all - git checkout stable - git merge master -m 'merge from master' - oasis setup - git commit -a -m 'oasis files' - git push origin - git checkout master - -VERSION=$(shell awk '/^Version:/ {print $$2}' _oasis) +VERSION=$(shell awk '/^version:/ {print $$2}' sequence.opam) update_next_tag: @echo "update version to $(VERSION)..." diff --git a/_oasis b/_oasis deleted file mode 100644 index ce3ec32..0000000 --- a/_oasis +++ /dev/null @@ -1,103 +0,0 @@ -OASISFormat: 0.4 -Name: sequence -Version: 0.11 -Homepage: https://github.com/c-cube/sequence -Authors: Simon Cruanes -License: BSD-2-clause -LicenseFile: LICENSE -Plugins: META (0.3), DevFiles (0.3) -BuildTools: ocamlbuild - -Synopsis: Simple sequence (iterator) datatype and combinators -Description: - Simple sequence datatype, intended to transfer a finite number of - elements from one data structure to another. Some transformations on sequences, - like `filter`, `map`, `take`, `drop` and `append` can be performed before the - sequence is iterated/folded on. - -Flag bench - Description: enable benchmarks (require library Benchmark) - Default: false - -Flag invert - Description: build sequence.invert (requires Delimcc) - Default: false - -Flag bigarray - Description: build sequence.bigarray (requires bigarray) - Default: true - -Library "sequence" - Path: src/ - Modules: Sequence, SequenceLabels - BuildDepends: bytes, result - -Library "invert" - Path: src/invert - Build$: flag(invert) - Install$: flag(invert) - Modules: SequenceInvert - FindlibName: invert - FindlibParent: sequence - BuildDepends: sequence,delimcc - -Library "bigarray" - Path: src/bigarray - Build$: flag(bigarray) - Install$: flag(bigarray) - Modules: SequenceBigarray - FindlibName: bigarray - FindlibParent: sequence - BuildDepends: sequence,bigarray - -Document sequence - Title: Sequence docs - Type: ocamlbuild (0.3) - BuildTools+: ocamldoc - Install: true - XOCamlbuildPath: . - XOCamlbuildLibraries: sequence - -PreBuildCommand: make qtest-gen - -Executable run_qtest - Path: qtest/ - Install: false - CompiledObject: native - MainIs: run_qtest.ml - Build$: flag(tests) - BuildDepends: sequence, qcheck - -Test all - Command: ./run_qtest.native - TestTools: run_qtest - Run$: flag(tests) - -Executable benchs - Path: bench - Install: false - CompiledObject: native - Build$: flag(bench) - BuildDepends: sequence,benchmark - MainIs: benchs.ml - -Executable bench_persistent - Path: bench - Install: false - CompiledObject: native - Build$: flag(bench) - BuildDepends: sequence,benchmark - MainIs: bench_persistent.ml - -Executable bench_persistent_read - Path: bench - Install: false - CompiledObject: native - Build$: flag(bench) - BuildDepends: sequence,benchmark - MainIs: bench_persistent_read.ml - -SourceRepository head - Type: git - Location: https://github.com/c-cube/sequence - Browser: https://github.com/c-cube/sequence/tree/master/src diff --git a/_tags b/_tags deleted file mode 100644 index 2e4613b..0000000 --- a/_tags +++ /dev/null @@ -1,35 +0,0 @@ -# OASIS_START -# DO NOT EDIT (digest: ffd3fbaf00b431777fea1b8279203bf9) -# Ignore VCS directories, you can use the same kind of rule outside -# OASIS_START/STOP if you want to exclude directories that contains -# useless stuff for the build process -<**/.svn>: -traverse -<**/.svn>: not_hygienic -".bzr": -traverse -".bzr": not_hygienic -".hg": -traverse -".hg": not_hygienic -".git": -traverse -".git": not_hygienic -"_darcs": -traverse -"_darcs": not_hygienic -# Library sequence -"sequence.cmxs": use_sequence -# Executable benchs -"bench/benchs.native": pkg_benchmark -"bench/benchs.native": use_sequence -# Executable bench_persistent -"bench/bench_persistent.native": pkg_benchmark -"bench/bench_persistent.native": use_sequence -# Executable bench_persistent_read -"bench/bench_persistent_read.native": pkg_benchmark -"bench/bench_persistent_read.native": use_sequence -: pkg_benchmark -: use_sequence -# OASIS_STOP -true: safe_string, bin_annot, color(always) -<**/*.ml>: warn(+a-4-44-48@8) -: warn(-33) -true: mark_tag_used -<**/*.cmx>: optimize(3) -: nolabels diff --git a/bench/jbuild b/bench/jbuild new file mode 100644 index 0000000..a78ee5d --- /dev/null +++ b/bench/jbuild @@ -0,0 +1,8 @@ + +(executables + ((names (bench_persistent_read bench_persistent)) + (libraries (sequence benchmark)) + (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always)) + (ocamlopt_flags (:standard -O3 -color always + -unbox-closures -unbox-closures-factor 20)) + )) diff --git a/examples/jbuild b/examples/jbuild new file mode 100644 index 0000000..1ff3186 --- /dev/null +++ b/examples/jbuild @@ -0,0 +1,8 @@ + +(executable + ((name test_sexpr) + (libraries (sequence)) + (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always)) + (ocamlopt_flags (:standard -O3 -color always + -unbox-closures -unbox-closures-factor 20)) + )) diff --git a/myocamlbuild.ml b/myocamlbuild.ml deleted file mode 100644 index 1f96966..0000000 --- a/myocamlbuild.ml +++ /dev/null @@ -1,609 +0,0 @@ -(* OASIS_START *) -(* DO NOT EDIT (digest: 958ece46307b808952e439e1cc47a739) *) -module OASISGettext = struct -(* # 22 "src/oasis/OASISGettext.ml" *) - - - let ns_ str = - str - - - let s_ str = - str - - - let f_ (str: ('a, 'b, 'c, 'd) format4) = - str - - - let fn_ fmt1 fmt2 n = - if n = 1 then - fmt1^^"" - else - fmt2^^"" - - - let init = - [] - - -end - -module OASISExpr = struct -(* # 22 "src/oasis/OASISExpr.ml" *) - - - - - - open OASISGettext - - - type test = string - - - type flag = string - - - type t = - | EBool of bool - | ENot of t - | EAnd of t * t - | EOr of t * t - | EFlag of flag - | ETest of test * string - - - - type 'a choices = (t * 'a) list - - - let eval var_get t = - let rec eval' = - function - | EBool b -> - b - - | ENot e -> - not (eval' e) - - | EAnd (e1, e2) -> - (eval' e1) && (eval' e2) - - | EOr (e1, e2) -> - (eval' e1) || (eval' e2) - - | EFlag nm -> - let v = - var_get nm - in - assert(v = "true" || v = "false"); - (v = "true") - - | ETest (nm, vl) -> - let v = - var_get nm - in - (v = vl) - in - eval' t - - - let choose ?printer ?name var_get lst = - let rec choose_aux = - function - | (cond, vl) :: tl -> - if eval var_get cond then - vl - else - choose_aux tl - | [] -> - let str_lst = - if lst = [] then - s_ "" - else - String.concat - (s_ ", ") - (List.map - (fun (cond, vl) -> - match printer with - | Some p -> p vl - | None -> s_ "") - lst) - in - match name with - | Some nm -> - failwith - (Printf.sprintf - (f_ "No result for the choice list '%s': %s") - nm str_lst) - | None -> - failwith - (Printf.sprintf - (f_ "No result for a choice list: %s") - str_lst) - in - choose_aux (List.rev lst) - - -end - - -# 132 "myocamlbuild.ml" -module BaseEnvLight = struct -(* # 22 "src/base/BaseEnvLight.ml" *) - - - module MapString = Map.Make(String) - - - type t = string MapString.t - - - let default_filename = - Filename.concat - (Sys.getcwd ()) - "setup.data" - - - let load ?(allow_empty=false) ?(filename=default_filename) () = - if Sys.file_exists filename then - begin - let chn = - open_in_bin filename - in - let st = - Stream.of_channel chn - in - let line = - ref 1 - in - let st_line = - Stream.from - (fun _ -> - try - match Stream.next st with - | '\n' -> incr line; Some '\n' - | c -> Some c - with Stream.Failure -> None) - in - let lexer = - Genlex.make_lexer ["="] st_line - in - let rec read_file mp = - match Stream.npeek 3 lexer with - | [Genlex.Ident nm; Genlex.Kwd "="; Genlex.String value] -> - Stream.junk lexer; - Stream.junk lexer; - Stream.junk lexer; - read_file (MapString.add nm value mp) - | [] -> - mp - | _ -> - failwith - (Printf.sprintf - "Malformed data file '%s' line %d" - filename !line) - in - let mp = - read_file MapString.empty - in - close_in chn; - mp - end - else if allow_empty then - begin - MapString.empty - end - else - begin - failwith - (Printf.sprintf - "Unable to load environment, the file '%s' doesn't exist." - filename) - end - - - let rec var_expand str env = - let buff = - Buffer.create ((String.length str) * 2) - in - Buffer.add_substitute - buff - (fun var -> - try - var_expand (MapString.find var env) env - with Not_found -> - failwith - (Printf.sprintf - "No variable %s defined when trying to expand %S." - var - str)) - str; - Buffer.contents buff - - - let var_get name env = - var_expand (MapString.find name env) env - - - let var_choose lst env = - OASISExpr.choose - (fun nm -> var_get nm env) - lst -end - - -# 237 "myocamlbuild.ml" -module MyOCamlbuildFindlib = struct -(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildFindlib.ml" *) - - - (** OCamlbuild extension, copied from - * http://brion.inria.fr/gallium/index.php/Using_ocamlfind_with_ocamlbuild - * by N. Pouillard and others - * - * Updated on 2009/02/28 - * - * Modified by Sylvain Le Gall - *) - open Ocamlbuild_plugin - - - (* these functions are not really officially exported *) - let run_and_read = - Ocamlbuild_pack.My_unix.run_and_read - - - let blank_sep_strings = - Ocamlbuild_pack.Lexers.blank_sep_strings - - - let exec_from_conf exec = - let exec = - let env_filename = Pathname.basename BaseEnvLight.default_filename in - let env = BaseEnvLight.load ~filename:env_filename ~allow_empty:true () in - try - BaseEnvLight.var_get exec env - with Not_found -> - Printf.eprintf "W: Cannot get variable %s\n" exec; - exec - in - let fix_win32 str = - if Sys.os_type = "Win32" then begin - let buff = Buffer.create (String.length str) in - (* Adapt for windowsi, ocamlbuild + win32 has a hard time to handle '\\'. - *) - String.iter - (fun c -> Buffer.add_char buff (if c = '\\' then '/' else c)) - str; - Buffer.contents buff - end else begin - str - end - in - fix_win32 exec - - let split s ch = - let buf = Buffer.create 13 in - let x = ref [] in - let flush () = - x := (Buffer.contents buf) :: !x; - Buffer.clear buf - in - String.iter - (fun c -> - if c = ch then - flush () - else - Buffer.add_char buf c) - s; - flush (); - List.rev !x - - - let split_nl s = split s '\n' - - - let before_space s = - try - String.before s (String.index s ' ') - with Not_found -> s - - (* ocamlfind command *) - let ocamlfind x = S[Sh (exec_from_conf "ocamlfind"); x] - - (* This lists all supported packages. *) - let find_packages () = - List.map before_space (split_nl & run_and_read "ocamlfind list") - - - (* Mock to list available syntaxes. *) - let find_syntaxes () = ["camlp4o"; "camlp4r"] - - - let well_known_syntax = [ - "camlp4.quotations.o"; - "camlp4.quotations.r"; - "camlp4.exceptiontracer"; - "camlp4.extend"; - "camlp4.foldgenerator"; - "camlp4.listcomprehension"; - "camlp4.locationstripper"; - "camlp4.macro"; - "camlp4.mapgenerator"; - "camlp4.metagenerator"; - "camlp4.profiler"; - "camlp4.tracer" - ] - - - let dispatch = - function - | After_options -> - (* By using Before_options one let command line options have an higher - * priority on the contrary using After_options will guarantee to have - * the higher priority override default commands by ocamlfind ones *) - Options.ocamlc := ocamlfind & A"ocamlc"; - Options.ocamlopt := ocamlfind & A"ocamlopt"; - Options.ocamldep := ocamlfind & A"ocamldep"; - Options.ocamldoc := ocamlfind & A"ocamldoc"; - Options.ocamlmktop := ocamlfind & A"ocamlmktop"; - Options.ocamlmklib := ocamlfind & A"ocamlmklib" - - | After_rules -> - - (* When one link an OCaml library/binary/package, one should use - * -linkpkg *) - flag ["ocaml"; "link"; "program"] & A"-linkpkg"; - - (* For each ocamlfind package one inject the -package option when - * compiling, computing dependencies, generating documentation and - * linking. *) - List.iter - begin fun pkg -> - let base_args = [A"-package"; A pkg] in - (* TODO: consider how to really choose camlp4o or camlp4r. *) - let syn_args = [A"-syntax"; A "camlp4o"] in - let args = - (* Heuristic to identify syntax extensions: whether they end in - ".syntax"; some might not. - *) - if Filename.check_suffix pkg "syntax" || - List.mem pkg well_known_syntax then - syn_args @ base_args - else - base_args - in - flag ["ocaml"; "compile"; "pkg_"^pkg] & S args; - flag ["ocaml"; "ocamldep"; "pkg_"^pkg] & S args; - flag ["ocaml"; "doc"; "pkg_"^pkg] & S args; - flag ["ocaml"; "link"; "pkg_"^pkg] & S base_args; - flag ["ocaml"; "infer_interface"; "pkg_"^pkg] & S args; - end - (find_packages ()); - - (* Like -package but for extensions syntax. Morover -syntax is useless - * when linking. *) - List.iter begin fun syntax -> - flag ["ocaml"; "compile"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; - flag ["ocaml"; "ocamldep"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; - flag ["ocaml"; "doc"; "syntax_"^syntax] & S[A"-syntax"; A syntax]; - flag ["ocaml"; "infer_interface"; "syntax_"^syntax] & - S[A"-syntax"; A syntax]; - end (find_syntaxes ()); - - (* The default "thread" tag is not compatible with ocamlfind. - * Indeed, the default rules add the "threads.cma" or "threads.cmxa" - * options when using this tag. When using the "-linkpkg" option with - * ocamlfind, this module will then be added twice on the command line. - * - * To solve this, one approach is to add the "-thread" option when using - * the "threads" package using the previous plugin. - *) - flag ["ocaml"; "pkg_threads"; "compile"] (S[A "-thread"]); - flag ["ocaml"; "pkg_threads"; "doc"] (S[A "-I"; A "+threads"]); - flag ["ocaml"; "pkg_threads"; "link"] (S[A "-thread"]); - flag ["ocaml"; "pkg_threads"; "infer_interface"] (S[A "-thread"]); - flag ["ocaml"; "package(threads)"; "compile"] (S[A "-thread"]); - flag ["ocaml"; "package(threads)"; "doc"] (S[A "-I"; A "+threads"]); - flag ["ocaml"; "package(threads)"; "link"] (S[A "-thread"]); - flag ["ocaml"; "package(threads)"; "infer_interface"] (S[A "-thread"]); - - | _ -> - () -end - -module MyOCamlbuildBase = struct -(* # 22 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *) - - - (** Base functions for writing myocamlbuild.ml - @author Sylvain Le Gall - *) - - - - - - open Ocamlbuild_plugin - module OC = Ocamlbuild_pack.Ocaml_compiler - - - type dir = string - type file = string - type name = string - type tag = string - - -(* # 62 "src/plugins/ocamlbuild/MyOCamlbuildBase.ml" *) - - - type t = - { - lib_ocaml: (name * dir list * string list) list; - lib_c: (name * dir * file list) list; - flags: (tag list * (spec OASISExpr.choices)) list; - (* Replace the 'dir: include' from _tags by a precise interdepends in - * directory. - *) - includes: (dir * dir list) list; - } - - - let env_filename = - Pathname.basename - BaseEnvLight.default_filename - - - let dispatch_combine lst = - fun e -> - List.iter - (fun dispatch -> dispatch e) - lst - - - let tag_libstubs nm = - "use_lib"^nm^"_stubs" - - - let nm_libstubs nm = - nm^"_stubs" - - - let dispatch t e = - let env = - BaseEnvLight.load - ~filename:env_filename - ~allow_empty:true - () - in - match e with - | Before_options -> - let no_trailing_dot s = - if String.length s >= 1 && s.[0] = '.' then - String.sub s 1 ((String.length s) - 1) - else - s - in - List.iter - (fun (opt, var) -> - try - opt := no_trailing_dot (BaseEnvLight.var_get var env) - with Not_found -> - Printf.eprintf "W: Cannot get variable %s\n" var) - [ - Options.ext_obj, "ext_obj"; - Options.ext_lib, "ext_lib"; - Options.ext_dll, "ext_dll"; - ] - - | After_rules -> - (* Declare OCaml libraries *) - List.iter - (function - | nm, [], intf_modules -> - ocaml_lib nm; - let cmis = - List.map (fun m -> (String.uncapitalize m) ^ ".cmi") - intf_modules in - dep ["ocaml"; "link"; "library"; "file:"^nm^".cma"] cmis - | nm, dir :: tl, intf_modules -> - ocaml_lib ~dir:dir (dir^"/"^nm); - List.iter - (fun dir -> - List.iter - (fun str -> - flag ["ocaml"; "use_"^nm; str] (S[A"-I"; P dir])) - ["compile"; "infer_interface"; "doc"]) - tl; - let cmis = - List.map (fun m -> dir^"/"^(String.uncapitalize m)^".cmi") - intf_modules in - dep ["ocaml"; "link"; "library"; "file:"^dir^"/"^nm^".cma"] - cmis) - t.lib_ocaml; - - (* Declare directories dependencies, replace "include" in _tags. *) - List.iter - (fun (dir, include_dirs) -> - Pathname.define_context dir include_dirs) - t.includes; - - (* Declare C libraries *) - List.iter - (fun (lib, dir, headers) -> - (* Handle C part of library *) - flag ["link"; "library"; "ocaml"; "byte"; tag_libstubs lib] - (S[A"-dllib"; A("-l"^(nm_libstubs lib)); A"-cclib"; - A("-l"^(nm_libstubs lib))]); - - flag ["link"; "library"; "ocaml"; "native"; tag_libstubs lib] - (S[A"-cclib"; A("-l"^(nm_libstubs lib))]); - - flag ["link"; "program"; "ocaml"; "byte"; tag_libstubs lib] - (S[A"-dllib"; A("dll"^(nm_libstubs lib))]); - - (* When ocaml link something that use the C library, then one - need that file to be up to date. - *) - dep ["link"; "ocaml"; "program"; tag_libstubs lib] - [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; - - dep ["compile"; "ocaml"; "program"; tag_libstubs lib] - [dir/"lib"^(nm_libstubs lib)^"."^(!Options.ext_lib)]; - - (* TODO: be more specific about what depends on headers *) - (* Depends on .h files *) - dep ["compile"; "c"] - headers; - - (* Setup search path for lib *) - flag ["link"; "ocaml"; "use_"^lib] - (S[A"-I"; P(dir)]); - ) - t.lib_c; - - (* Add flags *) - List.iter - (fun (tags, cond_specs) -> - let spec = BaseEnvLight.var_choose cond_specs env in - let rec eval_specs = - function - | S lst -> S (List.map eval_specs lst) - | A str -> A (BaseEnvLight.var_expand str env) - | spec -> spec - in - flag tags & (eval_specs spec)) - t.flags - | _ -> - () - - - let dispatch_default t = - dispatch_combine - [ - dispatch t; - MyOCamlbuildFindlib.dispatch; - ] - - -end - - -# 594 "myocamlbuild.ml" -open Ocamlbuild_plugin;; -let package_default = - { - MyOCamlbuildBase.lib_ocaml = [("sequence", [], [])]; - lib_c = []; - flags = []; - includes = [] - } - ;; - -let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;; - -# 608 "myocamlbuild.ml" -(* OASIS_STOP *) -Ocamlbuild_plugin.dispatch dispatch_default;; diff --git a/qtest/Makefile b/qtest/Makefile new file mode 100644 index 0000000..09e30e4 --- /dev/null +++ b/qtest/Makefile @@ -0,0 +1,15 @@ + +QTEST_PREAMBLE='' +DONTTEST=../src/sequenceLabels.ml +QTESTABLE=$(filter-out $(DONTTEST), \ + $(wildcard ../src/*.ml) \ + $(wildcard ../src/*.mli) \ + ) + +qtest-gen: + @if which qtest > /dev/null ; then \ + qtest extract --preamble $(QTEST_PREAMBLE) \ + -o run_qtest.ml \ + $(QTESTABLE) 2> /dev/null ; \ + else touch qtest/run_qtest.ml ; \ + fi diff --git a/qtest/jbuild b/qtest/jbuild new file mode 100644 index 0000000..3b74acb --- /dev/null +++ b/qtest/jbuild @@ -0,0 +1,21 @@ + +(rule + ((targets (run_qtest.ml)) + (deps ((file Makefile))) + (fallback) + ;(libraries (qtest qcheck)) + (action + (run make qtest-gen)) + )) + +(executable + ((name run_qtest) + (libraries (sequence qcheck)) + )) + +(alias + ((name runtest) + (deps (run_qtest.exe)) + (action (run ${<})) + )) + diff --git a/opam b/sequence.opam similarity index 67% rename from opam rename to sequence.opam index 37ede30..18da15e 100644 --- a/opam +++ b/sequence.opam @@ -5,22 +5,15 @@ author: "Simon Cruanes" maintainer: "simon.cruanes.2007@m4x.org" license: "BSD-2-clauses" build: [ - ["./configure" "--disable-docs" - "--%{delimcc:enable}%-invert" - "--%{base-bigarray:enable}%-bigarray" - "--prefix" "%{prefix}%" - ] [make "build"] ] +install: ["jbuilder" "install"] build-doc: [ - ["./configure" "--enable-docs"] [make "doc"] ] build-test: [ - ["./configure" "--enable-tests"] [make "test"] ] -install: [make "install"] remove: [ ["ocamlfind" "remove" "sequence"] ] @@ -28,13 +21,17 @@ depends: [ "ocamlfind" "base-bytes" "result" - "ocamlbuild" {build} + "jbuilder" {build} "qcheck" {test} "qtest" {test} + "ocaml-version" { >= "4.02" } ] tags: [ "sequence" "iterator" "iter" "fold" ] homepage: "https://github.com/c-cube/sequence/" -depopts: ["delimcc" "base-bigarray"] +depopts: [ + "delimcc" + "base-bigarray" +] doc: "http://cedeela.fr/~simon/software/sequence/Sequence.html" bug-reports: "https://github.com/c-cube/sequence/issues" dev-repo: "https://github.com/c-cube/sequence.git" diff --git a/setup.ml b/setup.ml deleted file mode 100644 index fe8169f..0000000 --- a/setup.ml +++ /dev/null @@ -1,37 +0,0 @@ -(* setup.ml generated for the first time by OASIS v0.4.4 *) - -(* OASIS_START *) -(* DO NOT EDIT (digest: 9852805d5c19ca1cb6abefde2dcea323) *) -(******************************************************************************) -(* OASIS: architecture for building OCaml libraries and applications *) -(* *) -(* Copyright (C) 2011-2013, Sylvain Le Gall *) -(* Copyright (C) 2008-2011, OCamlCore SARL *) -(* *) -(* This library is free software; you can redistribute it and/or modify it *) -(* under the terms of the GNU Lesser General Public License as published by *) -(* the Free Software Foundation; either version 2.1 of the License, or (at *) -(* your option) any later version, with the OCaml static compilation *) -(* exception. *) -(* *) -(* This library is distributed in the hope that it will be useful, but *) -(* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *) -(* or FITNESS FOR A PARTICULAR PURPOSE. See the file COPYING for more *) -(* details. *) -(* *) -(* You should have received a copy of the GNU Lesser General Public License *) -(* along with this library; if not, write to the Free Software Foundation, *) -(* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *) -(******************************************************************************) - -let () = - try - Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") - with Not_found -> () -;; -#use "topfind";; -#require "oasis.dynrun";; -open OASISDynRun;; - -(* OASIS_STOP *) -let () = setup ();; diff --git a/src/bigarray/jbuild b/src/bigarray/jbuild new file mode 100644 index 0000000..e59b07f --- /dev/null +++ b/src/bigarray/jbuild @@ -0,0 +1,11 @@ + +(library + ((name sequence_bigarray) + (public_name sequence.bigarray) + (libraries (sequence bigarray)) + (wrapped false) + (optional) + (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -w -33 -safe-string -color always)) + (ocamlopt_flags (:standard -O3 -color always + -unbox-closures -unbox-closures-factor 20)) + )) diff --git a/src/invert/jbuild b/src/invert/jbuild new file mode 100644 index 0000000..3acdbc8 --- /dev/null +++ b/src/invert/jbuild @@ -0,0 +1,12 @@ + +(library + ((name sequence_invert) + (public_name sequence.invert) + (libraries (sequence delimcc)) + (optional) + (wrapped false) + (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always)) + (ocamlopt_flags (:standard -O3 -color always + -unbox-closures -unbox-closures-factor 20)) + )) + diff --git a/src/jbuild b/src/jbuild new file mode 100644 index 0000000..981b07e --- /dev/null +++ b/src/jbuild @@ -0,0 +1,11 @@ + +(library + ((name sequence) + (public_name sequence) + (wrapped false) + (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always -nolabels)) + (ocamlopt_flags (:standard -O3 -color always + -unbox-closures -unbox-closures-factor 20)) + (libraries (bytes result)) + )) + From f85bd00ac9d089ecd5e02d0d41232127876483e4 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 14 Jan 2018 16:31:53 -0600 Subject: [PATCH 08/10] remove delimcc sublib --- sequence.opam | 1 - src/invert/.merlin | 2 -- src/invert/SequenceInvert.ml | 62 ----------------------------------- src/invert/SequenceInvert.mli | 32 ------------------ src/invert/jbuild | 12 ------- 5 files changed, 109 deletions(-) delete mode 100644 src/invert/.merlin delete mode 100644 src/invert/SequenceInvert.ml delete mode 100644 src/invert/SequenceInvert.mli delete mode 100644 src/invert/jbuild diff --git a/sequence.opam b/sequence.opam index 18da15e..a515569 100644 --- a/sequence.opam +++ b/sequence.opam @@ -29,7 +29,6 @@ depends: [ tags: [ "sequence" "iterator" "iter" "fold" ] homepage: "https://github.com/c-cube/sequence/" depopts: [ - "delimcc" "base-bigarray" ] doc: "http://cedeela.fr/~simon/software/sequence/Sequence.html" diff --git a/src/invert/.merlin b/src/invert/.merlin deleted file mode 100644 index 3b9a31d..0000000 --- a/src/invert/.merlin +++ /dev/null @@ -1,2 +0,0 @@ -REC -PKG delimcc diff --git a/src/invert/SequenceInvert.ml b/src/invert/SequenceInvert.ml deleted file mode 100644 index 46efc69..0000000 --- a/src/invert/SequenceInvert.ml +++ /dev/null @@ -1,62 +0,0 @@ -(* -Copyright (c) 2014, Simon Cruanes -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other materials provided with -the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*) - -(** {1 Interface to Delimcc (Invert control flow)} *) - -type 'a gen = unit -> 'a option - -type 'a res = - | Start - | Yield of 'a - | Stop - -let _ret_none () = None -let _ret_unit () = () - -let to_gen seq = - let p = Delimcc.new_prompt () in - let _next = ref None in - ignore (Delimcc.push_prompt p - (fun () -> - Delimcc.take_subcont p (fun c () -> _next := Some c; Start); - seq - (fun x -> - Delimcc.take_subcont p (fun c () -> _next := Some c; Yield x) - ); - _next := None; - Stop - )); - (* call next subcont *) - let rec next () = - match !_next with - | None -> None - | Some f -> - begin match Delimcc.push_delim_subcont f _ret_unit with - | Start -> next () - | Yield x -> Some x - | Stop -> None - end - in - next diff --git a/src/invert/SequenceInvert.mli b/src/invert/SequenceInvert.mli deleted file mode 100644 index bd3c843..0000000 --- a/src/invert/SequenceInvert.mli +++ /dev/null @@ -1,32 +0,0 @@ -(* -Copyright (c) 2014, Simon Cruanes -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - -Redistributions of source code must retain the above copyright notice, this -list of conditions and the following disclaimer. Redistributions in binary -form must reproduce the above copyright notice, this list of conditions and the -following disclaimer in the documentation and/or other materials provided with -the distribution. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -*) - -(** {1 Interface to Delimcc (Invert control flow)} *) - -type 'a gen = unit -> 'a option - -val to_gen : 'a Sequence.t -> 'a gen -(** Use delimited continuations to iterate on the sequence step by step. - Relatively costly but still useful *) diff --git a/src/invert/jbuild b/src/invert/jbuild deleted file mode 100644 index 3acdbc8..0000000 --- a/src/invert/jbuild +++ /dev/null @@ -1,12 +0,0 @@ - -(library - ((name sequence_invert) - (public_name sequence.invert) - (libraries (sequence delimcc)) - (optional) - (wrapped false) - (flags (:standard -w +a-4-42-44-48-50-58-32-60@8 -safe-string -color always)) - (ocamlopt_flags (:standard -O3 -color always - -unbox-closures -unbox-closures-factor 20)) - )) - From eb56b704174e855d98c5b8f2588b8fbd9e22066d Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 14 Jan 2018 16:35:17 -0600 Subject: [PATCH 09/10] remove junk files --- configure | 27 --------------------------- sequence.odocl | 4 ---- 2 files changed, 31 deletions(-) delete mode 100755 configure delete mode 100644 sequence.odocl diff --git a/configure b/configure deleted file mode 100755 index 6acfaeb..0000000 --- a/configure +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# OASIS_START -# DO NOT EDIT (digest: dc86c2ad450f91ca10c931b6045d0499) -set -e - -FST=true -for i in "$@"; do - if $FST; then - set -- - FST=false - fi - - case $i in - --*=*) - ARG=${i%%=*} - VAL=${i##*=} - set -- "$@" "$ARG" "$VAL" - ;; - *) - set -- "$@" "$i" - ;; - esac -done - -ocaml setup.ml -configure "$@" -# OASIS_STOP diff --git a/sequence.odocl b/sequence.odocl deleted file mode 100644 index 2f635d2..0000000 --- a/sequence.odocl +++ /dev/null @@ -1,4 +0,0 @@ -# OASIS_START -# DO NOT EDIT (digest: 3ff39d3acb327553070a64ef0cb321d5) -Sequence -# OASIS_STOP From 98aa2286556460c0aef2ecf9a9a825cb26297cb1 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Sun, 14 Jan 2018 16:36:45 -0600 Subject: [PATCH 10/10] prepare for 1.0 --- README.adoc | 4 ++-- sequence.opam | 2 +- src/Sequence.mli | 12 ++++++------ src/SequenceLabels.mli | 12 ++++++------ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/README.adoc b/README.adoc index 60ce610..d158824 100644 --- a/README.adoc +++ b/README.adoc @@ -25,13 +25,13 @@ To get an overview of sequence, its origins and why it was created, you can start with http://cedeela.fr/~simon/talks/sequence.pdf[the slides of a talk] I (@c-cube) made at some OCaml meeting. -See https://c-cube.github.io/sequence/api/[the online API] +See https://c-cube.github.io/sequence/[the online API] for more details on the set of available functions. == Build 1. via opam `opam install sequence` -2. manually (need OCaml >= 3.12): `make all install` +2. manually (need OCaml >= 4.02.0): `make all install` If you have https://github.com/vincent-hugot/iTeML[qtest] installed, you can build and run tests with diff --git a/sequence.opam b/sequence.opam index a515569..45b873e 100644 --- a/sequence.opam +++ b/sequence.opam @@ -1,6 +1,6 @@ opam-version: "1.2" name: "sequence" -version: "0.11" +version: "1.0" author: "Simon Cruanes" maintainer: "simon.cruanes.2007@m4x.org" license: "BSD-2-clauses" diff --git a/src/Sequence.mli b/src/Sequence.mli index b6a2fdb..bbddc5a 100644 --- a/src/Sequence.mli +++ b/src/Sequence.mli @@ -37,7 +37,7 @@ type +'a t = ('a -> unit) -> unit type +'a sequence = 'a t (** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit] - has been removed and subsumed by [('a * 'b) t] @since NEXT_RELEASE *) + has been removed and subsumed by [('a * 'b) t] @since 1.0 *) type 'a equal = 'a -> 'a -> bool type 'a hash = 'a -> int @@ -226,7 +226,7 @@ val filter_mapi : (int -> 'a -> 'b option) -> 'a t -> 'b t val filter_count : ('a -> bool) -> 'a t -> int (** Count how many elements satisfy the given predicate - @since NEXT_RELEASE *) + @since 1.0 *) val intersperse : 'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *) @@ -234,15 +234,15 @@ val intersperse : 'a -> 'a t -> 'a t val keep_some : 'a option t -> 'a t (** [filter_some l] retains only elements of the form [Some x]. Same as [filter_map (fun x->x)] - @since NEXT_RELEASE *) + @since 1.0 *) val keep_ok : ('a, _) Result.result t -> 'a t (** [keep_ok l] retains only elements of the form [Ok x]. - @since NEXT_RELEASE *) + @since 1.0 *) val keep_error : (_, 'e) Result.result t -> 'e t (** [keep_error l] retains only elements of the form [Error x]. - @since NEXT_RELEASE *) + @since 1.0 *) (** {2 Caching} *) @@ -485,7 +485,7 @@ val rev : 'a t -> 'a t val zip_i : 'a t -> (int * 'a) t (** Zip elements of the sequence with their index in the sequence. - Changed type @since NEXT_RELEASE to just give a sequence of pairs *) + Changed type @since 1.0 to just give a sequence of pairs *) val fold2 : ('c -> 'a -> 'b -> 'c) -> 'c -> ('a * 'b) t -> 'c diff --git a/src/SequenceLabels.mli b/src/SequenceLabels.mli index 809c054..0cd7dd3 100644 --- a/src/SequenceLabels.mli +++ b/src/SequenceLabels.mli @@ -15,7 +15,7 @@ type +'a t = ('a -> unit) -> unit type +'a sequence = 'a t (** {b NOTE} Type [('a, 'b) t2 = ('a -> 'b -> unit) -> unit] - has been removed and subsumed by [('a * 'b) t] @since NEXT_RELEASE *) + has been removed and subsumed by [('a * 'b) t] @since 1.0 *) type 'a equal = 'a -> 'a -> bool type 'a hash = 'a -> int @@ -199,7 +199,7 @@ val seq_list_map : f:('a -> 'b t) -> 'a list -> 'b list t val filter_count : f:('a -> bool) -> 'a t -> int (** Count how many elements satisfy the given predicate - @since NEXT_RELEASE *) + @since 1.0 *) val intersperse : x:'a -> 'a t -> 'a t (** Insert the single element between every element of the sequence *) @@ -207,15 +207,15 @@ val intersperse : x:'a -> 'a t -> 'a t val keep_some : 'a option t -> 'a t (** [filter_some l] retains only elements of the form [Some x]. Same as [filter_map (fun x->x)] - @since NEXT_RELEASE *) + @since 1.0 *) val keep_ok : ('a, _) Result.result t -> 'a t (** [keep_ok l] retains only elements of the form [Ok x]. - @since NEXT_RELEASE *) + @since 1.0 *) val keep_error : (_, 'e) Result.result t -> 'e t (** [keep_error l] retains only elements of the form [Error x]. - @since NEXT_RELEASE *) + @since 1.0 *) (** {2 Caching} *) @@ -457,7 +457,7 @@ val rev : 'a t -> 'a t val zip_i : 'a t -> (int * 'a) t (** Zip elements of the sequence with their index in the sequence. - Changed type @since NEXT_RELEASE to just give a sequence of pairs *) + Changed type @since 1.0 to just give a sequence of pairs *) val fold2 : f:('c -> 'a -> 'b -> 'c) -> init:'c -> ('a * 'b) t -> 'c