Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package ocaml-gen for openSUSE:Factory checked in at 2022-04-06 21:51:15 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ocaml-gen (Old) and /work/SRC/openSUSE:Factory/.ocaml-gen.new.1900 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ocaml-gen" Wed Apr 6 21:51:15 2022 rev:8 rq:967054 version:1.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ocaml-gen/ocaml-gen.changes 2021-05-07 16:46:13.984196251 +0200 +++ /work/SRC/openSUSE:Factory/.ocaml-gen.new.1900/ocaml-gen.changes 2022-04-06 21:51:33.643519707 +0200 @@ -1,0 +2,7 @@ +Mon Apr 4 04:04:04 UTC 2022 - oher...@suse.de + +- Update to version 1.0 + See included CHANGELOG.md for details +- Remove obsolete ocaml-gen.patch + +------------------------------------------------------------------- Old: ---- ocaml-gen-0.5.3.tar.xz ocaml-gen.patch New: ---- ocaml-gen-1.0.tar.xz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ocaml-gen.spec ++++++ --- /var/tmp/diff_new_pack.WluaZf/_old 2022-04-06 21:51:34.155513864 +0200 +++ /var/tmp/diff_new_pack.WluaZf/_new 2022-04-06 21:51:34.159513818 +0200 @@ -1,7 +1,7 @@ # # spec file for package ocaml-gen # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,35 +16,35 @@ # -%define build_flavor @BUILD_FLAVOR@%{nil} -%if "%{build_flavor}" == "testsuite" +%define build_flavor @BUILD_FLAVOR@%nil +%if "%build_flavor" == "testsuite" %define nsuffix -testsuite %else -%define nsuffix %{nil} +%define nsuffix %nil %endif %define pkg ocaml-gen -Name: %{pkg}%{nsuffix} -Version: 0.5.3 +Name: %pkg%nsuffix +Version: 1.0 Release: 0 %{?ocaml_preserve_bytecode} Summary: Simple, efficient iterators for OCaml License: BSD-2-Clause Group: Development/Languages/OCaml URL: https://opam.ocaml.org/packages/gen -Source0: %{pkg}-%{version}.tar.xz -Patch0: %{pkg}.patch +Source0: %pkg-%version.tar.xz BuildRequires: ocaml BuildRequires: ocaml-dune -BuildRequires: ocaml-rpm-macros >= 20210409 +BuildRequires: ocaml-rpm-macros >= 20220222 %if 1 BuildRequires: ocamlfind(bytes) BuildRequires: ocamlfind(dune.configurator) +BuildRequires: ocamlfind(seq) %endif -%if "%{build_flavor}" == "testsuite" +%if "%build_flavor" == "testsuite" BuildRequires: ocamlfind(gen) -BuildRequires: ocamlfind(oUnit) +BuildRequires: ocamlfind(ounit2) BuildRequires: ocamlfind(qcheck) BuildRequires: ocamlfind(qtest) %endif @@ -55,41 +55,41 @@ %package devel -Summary: Development files for %{name} +Summary: Development files for %name Group: Development/Languages/OCaml -Requires: %{name} = %{version} +Requires: %name = %version %description devel -The %{name}-devel package contains libraries and signature files for -developing applications that use %{name}. +The %name-devel package contains libraries and signature files for +developing applications that use %name. %prep -%autosetup -p1 -n %{pkg}-%{version} +%autosetup -p1 -n %pkg-%version %build dune_release_pkgs='gen' %ocaml_dune_setup -%if "%{build_flavor}" == "" +%if "%build_flavor" == "" %ocaml_dune_build %endif %install -%if "%{build_flavor}" == "" +%if "%build_flavor" == "" %ocaml_dune_install %ocaml_create_file_list %endif -%if "%{build_flavor}" == "testsuite" +%if "%build_flavor" == "testsuite" %check %ocaml_dune_test %endif -%if "%{build_flavor}" == "" -%files -f %{name}.files +%if "%build_flavor" == "" +%files -f %name.files %doc README.md -%files devel -f %{name}.files.devel +%files devel -f %name.files.devel %endif ++++++ _service ++++++ --- /var/tmp/diff_new_pack.WluaZf/_old 2022-04-06 21:51:34.203513316 +0200 +++ /var/tmp/diff_new_pack.WluaZf/_new 2022-04-06 21:51:34.207513271 +0200 @@ -1,7 +1,7 @@ <services> <service name="tar_scm" mode="disabled"> <param name="filename">ocaml-gen</param> - <param name="revision">80f748cad171740789ebd4109f360609eab1f5ab</param> + <param name="revision">2ab29e69102b5bd4b4e2d3fca3d6b3b84c985446</param> <param name="scm">git</param> <param name="submodules">disable</param> <param name="url">https://github.com/c-cube/gen.git</param> ++++++ ocaml-gen-0.5.3.tar.xz -> ocaml-gen-1.0.tar.xz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/.github/workflows/gh-pages.yml new/ocaml-gen-1.0/.github/workflows/gh-pages.yml --- old/ocaml-gen-0.5.3/.github/workflows/gh-pages.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-gen-1.0/.github/workflows/gh-pages.yml 2022-01-21 19:13:43.000000000 +0100 @@ -0,0 +1,43 @@ +name: github pages + +on: + push: + branches: + - master # Set a branch name to trigger deployment + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@main + + - name: Cache opam + id: cache-opam + uses: actions/cache@v2 + with: + path: ~/.opam + key: opam-ubuntu-latest-4.12.0 + + - uses: avsm/setup-ocaml@v1 + with: + ocaml-version: '4.12.0' + + - name: Pin + run: opam pin -n . + + - name: Depext + run: opam depext -yt gen + + - name: Deps + run: opam install -d . --deps-only + + - name: Build + run: opam exec -- dune build @doc + + - name: Deploy + uses: peaceiris/actions-gh-pages@v3 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_build/default/_doc/_html/ + destination_dir: dev + enable_jekyll: true diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/.github/workflows/main.yml new/ocaml-gen-1.0/.github/workflows/main.yml --- old/ocaml-gen-0.5.3/.github/workflows/main.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-gen-1.0/.github/workflows/main.yml 2022-01-21 19:13:43.000000000 +0100 @@ -0,0 +1,32 @@ +name: build +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + run: + name: Build + strategy: + matrix: + os: + #- macos-latest # too slow + - ubuntu-latest + - windows-latest + ocaml-compiler: + - 4.03.x + - 4.12.x + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: ocaml/setup-ocaml@v2 + with: + ocaml-compiler: ${{ matrix.ocaml-compiler }} + - run: opam pin -n . + - run: opam depext -yt gen + - run: opam install -t . --deps-only + - run: opam exec -- dune build + - run: opam exec -- dune runtest + if: ${{ matrix.os == 'ubuntu-latest'}} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/.travis.yml new/ocaml-gen-1.0/.travis.yml --- old/ocaml-gen-0.5.3/.travis.yml 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/.travis.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,19 +0,0 @@ -language: c -install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh -script: bash -ex .travis-docker.sh -services: -- docker -env: - global: - - PINS="gen:." - - DISTRO="ubuntu-16.04" - - PACKAGE="gen" - matrix: - - OCAML_VERSION="4.03" - #- OCAML_VERSION="4.04" - #- PACKAGE="iter" OCAML_VERSION="4.05" EXTRA_DEPS="base-bigarray" - - OCAML_VERSION="4.06" - - OCAML_VERSION="4.07" - - OCAML_VERSION="4.08" - #- OCAML_VERSION="4.09" - - OCAML_VERSION="4.10" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/CHANGELOG.md new/ocaml-gen-1.0/CHANGELOG.md --- old/ocaml-gen-0.5.3/CHANGELOG.md 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/CHANGELOG.md 2022-01-21 19:13:43.000000000 +0100 @@ -1,20 +1,26 @@ # Changelog -# 0.5.3 +## 1.0 + +- add `{of_seq,to_iter,persistent_to_seq,persistent_lazy_to_seq}` +- depend on seq +- manual use of qtest, remove the qtestlib backend (more robust) + +## 0.5.3 - fix npm-package contents to actually include compiled output. (oops!) -# 0.5.2 +## 0.5.2 - explicitly support BuckleScript, and publish to npm as bs-gen - transition to updated dune (jbuilder), and opam 2.0 -# 0.5.1 +## 0.5.1 - refactor to use match-with-exception from OCaml 4.02 - transition to jbuilder -# 0.5 +## 0.5 - fix small problem with safe-string - move to safe-string, for compatibility with 4.06.0 @@ -22,7 +28,7 @@ - rename parameter of `int_range` from `by` to `step` - add `?(by=1)` to `int_range` -# 0.4 +## 0.4 - update `GenLabels` with missing functions - add `Gen.peek_n` @@ -36,7 +42,7 @@ * add ocp-indent file, update header, reindent files * move code to src/ -# 0.3 +## 0.3 - add `Gen.return` - fix overflow in `Gen.flat_map`; add regression test @@ -46,7 +52,7 @@ - add `Gen.IO.{with_lines, write_lines}` - update benchmarks to use Benchmark.Tree -# 0.2.4 +## 0.2.4 - `GenLabels` module - `fold_while` function @@ -54,7 +60,7 @@ - updated doc to make clear that combinators consume their generator argument - add missing @since; expose infix operators -# 0.2.3 +## 0.2.3 - updated .mli to replace "enum" with "gen" - `Gen.persistent_lazy` now exposes caching parameters related to `GenMList.of_gen_lazy` @@ -67,7 +73,7 @@ - add `permutations_heap` for array-based permutations; add a corresponding benchmark to compare - license file -# 0.2.2 +## 0.2.2 - do not depend on qtest - better combinatorics (`permutations`, `power_set`, `combinations`) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/Makefile new/ocaml-gen-1.0/Makefile --- old/ocaml-gen-0.5.3/Makefile 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/Makefile 2022-01-21 19:13:43.000000000 +0100 @@ -20,10 +20,8 @@ find -name '*.ml' -or -name '*.mli' | xargs sed -i "s/NEXT_VERSION/$(VERSION)/g" find -name '*.ml' -or -name '*.mli' | xargs sed -i "s/NEXT_RELEASE/$(VERSION)/g" +WATCH?=@all watch: - while find src/ bench/ -print0 | xargs -0 inotifywait -e delete_self -e modify ; do \ - echo "============ at `date` ==========" ; \ - make ; \ - done + @dune build $(WATCH) -w -.PHONY: update_next_tag release +.PHONY: update_next_tag diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/README.md new/ocaml-gen-1.0/README.md --- old/ocaml-gen-0.5.3/README.md 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/README.md 2022-01-21 19:13:43.000000000 +0100 @@ -1,4 +1,4 @@ -# Gen [](https://travis-ci.org/c-cube/gen) +# Gen [](https://github.com/c-cube/gen/actions/workflows/main.yml) Iterators for OCaml, both restartable and consumable. The implementation keeps a good balance between simplicity and performance. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/gen.opam new/ocaml-gen-1.0/gen.opam --- old/ocaml-gen-0.5.3/gen.opam 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/gen.opam 2022-01-21 19:13:43.000000000 +0100 @@ -3,19 +3,22 @@ synopsis: "Iterators for OCaml, both restartable and consumable" author: [ "Simon Cruanes" "ELLIOTTCABLE" ] name: "gen" -version: "0.5.3" +version: "1.0" +license: "BSD-2-Clause" build: [ - ["dune" "build" "@install" "-p" name] - ["dune" "runtest" "-p" name] {with-test} - ["dune" "build" "@doc" "-p" name] {with-doc} + ["dune" "build" "@install" "-p" name "-j" jobs] + ["dune" "runtest" "-p" name "-j" jobs] {with-test} + ["dune" "build" "@doc" "-p" name "-j" jobs] {with-doc} ] depends: [ "dune" {>= "1.1"} "dune-configurator" "base-bytes" + "seq" "odoc" {with-doc} "qcheck" {with-test} "qtest" {with-test} + "ounit2" {with-test} "ocaml" { >= "4.03.0" } ] tags: [ "gen" "iterator" "iter" "fold" ] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/qtest/Makefile new/ocaml-gen-1.0/qtest/Makefile --- old/ocaml-gen-0.5.3/qtest/Makefile 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-gen-1.0/qtest/Makefile 2022-01-21 19:13:43.000000000 +0100 @@ -0,0 +1,17 @@ + +QTEST_PREAMBLE=' ' +DONTTEST=../src/mkflags.ml ../src/mkshims.ml +QTESTABLE=$(filter-out $(DONTTEST), \ + $(wildcard ../src/*.ml) \ + $(wildcard ../src/*.mli) \ + ) + +qtest-gen: + @rm run_qtest.ml 2>/dev/null || true + @if which qtest > /dev/null ; then \ + qtest extract -o run_qtest.ml \ + $(QTESTABLE) 2> /dev/null ; \ + else touch run_qtest.ml ; \ + fi + +.PHONY: qtest-gen diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/qtest/dune new/ocaml-gen-1.0/qtest/dune --- old/ocaml-gen-0.5.3/qtest/dune 1970-01-01 01:00:00.000000000 +0100 +++ new/ocaml-gen-1.0/qtest/dune 2022-01-21 19:13:43.000000000 +0100 @@ -0,0 +1,17 @@ + +(rule + (targets run_qtest.ml) + (deps Makefile (source_tree ../src)) ; (glob_files ../src/**/*.ml{,i}))) + (mode fallback) + (action (run make qtest-gen))) + +(executable + (name run_qtest) + (flags :standard -warn-error -a+8 -safe-string -w -33) + (libraries gen ounit2 qcheck)) + +(alias + (name runtest) + (deps run_qtest.exe) + (action (run %{deps}))) + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/dune new/ocaml-gen-1.0/src/dune --- old/ocaml-gen-0.5.3/src/dune 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/dune 2022-01-21 19:13:43.000000000 +0100 @@ -21,6 +21,5 @@ (modules Gen GenLabels GenM GenClone GenMList GenM_intf Gen_intf GenLabels_intf GenShims_) (flags :standard -warn-error -a+8 -safe-string -nolabels) (ocamlopt_flags :standard (:include flambda.flags)) - (libraries bytes) - (inline_tests (backend qtest.lib))) + (libraries bytes seq)) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/gen.ml new/ocaml-gen-1.0/src/gen.ml --- old/ocaml-gen-0.5.3/src/gen.ml 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/gen.ml 2022-01-21 19:13:43.000000000 +0100 @@ -1,8 +1,6 @@ (* This file is free software, part of gen. See file "license" for more details. *) -(** {1 Restartable generators} *) - (** {2 Global type declarations} *) type 'a t = unit -> 'a option @@ -1596,6 +1594,15 @@ to_buffer buf s; Buffer.contents buf +let of_seq seq : _ t = + let seq = ref seq in + fun () -> + match !seq () with + | Seq.Nil -> None + | Seq.Cons (x,tl) -> + seq := tl; + Some x + let rand_int i = repeatedly (fun () -> Random.int i) @@ -1876,6 +1883,8 @@ let to_buffer buf s = to_buffer buf (s ()) + let to_iter s yield = iter yield s + let rand_int i () = rand_int i let int_range ?step i j () = int_range ?step i j @@ -1905,6 +1914,9 @@ let mlist = GenMList.of_gen_lazy ?max_chunk_size ?caching g in cached := Some mlist; GenMList.to_gen mlist + + let of_seq seq : _ t = + fun () -> of_seq seq end (** {2 Generator functions} *) @@ -1916,6 +1928,21 @@ let l = GenMList.of_gen gen in fun () -> GenMList.to_gen l +(*$inject + let rec seq_take i seq () = + if i=0 then Seq.Nil + else match seq() with + | Seq.Nil -> Seq.Nil + | Seq.Cons (x,tl) -> Seq.Cons (x, seq_take (i-1) tl) + + let seq_to_list seq = + let rec aux acc s = match s() with + | Seq.Nil -> List.rev acc + | Seq.Cons (x,tl) -> aux (x::acc) tl + in + aux [] seq +*) + (*$T let g = 1--10 in let g' = persistent g in \ Restart.to_list g' = Restart.to_list g' @@ -1923,6 +1950,19 @@ Restart.to_list g' = [1;2;3;4;5;6;7;8;9;10] *) +let persistent_to_seq gen : _ Seq.t = + let l = GenMList.of_gen gen in + GenMList.to_seq l + +(*$T + let g = 1--100_000 in \ + let seq = persistent_to_seq g in \ + (seq |> seq_take 100 |> seq_to_list = (1--100 |> to_list)) && \ + (seq |> seq_take 200 |> seq_to_list = (1--200 |> to_list)) && \ + (seq |> seq_take 80_000 |> seq_to_list = (1--80_000 |> to_list)) && \ + (seq |> seq_take 50_000 |> seq_to_list = (1--50_000 |> to_list)) +*) + (*$R let i = ref 0 in let gen () = @@ -1945,6 +1985,21 @@ (g' () |> take 200 |> to_list = (1--200 |> to_list)) *) +let persistent_lazy_to_seq ?caching ?max_chunk_size gen : _ Seq.t = + let l = GenMList.of_gen_lazy ?max_chunk_size ?caching gen in + GenMList.to_seq l + +(*$T + let g = 1--1_000_000_000 in \ + let seq = persistent_lazy_to_seq g in \ + (seq |> seq_take 100 |> seq_to_list = (1--100 |> to_list)) && \ + (seq |> seq_take 200 |> seq_to_list = (1--200 |> to_list)) && \ + (seq |> seq_take 80_000 |> seq_to_list = (1--80_000 |> to_list)) && \ + (seq |> seq_take 50_000 |> seq_to_list = (1--50_000 |> to_list)) +*) + +let to_iter g yield = iter yield g + let peek g = let state = ref `Start in let rec next() = match !state with diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/gen.mli new/ocaml-gen-1.0/src/gen.mli --- old/ocaml-gen-0.5.3/src/gen.mli 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/gen.mli 2022-01-21 19:13:43.000000000 +0100 @@ -66,7 +66,8 @@ val lift2 : ('a gen -> 'b gen -> 'c) -> 'a t -> 'b t -> 'c - val of_gen : ?caching:bool -> ?max_chunk_size:int -> + val of_gen : + ?caching:bool -> ?max_chunk_size:int -> 'a gen -> 'a t (** Use {!persistent_lazy} to convert a one-shot generator into a restartable one. @@ -81,7 +82,8 @@ on it several times later. If possible, consider using combinators from {!Restart} directly instead. *) -val persistent_lazy : ?caching:bool -> ?max_chunk_size:int -> +val persistent_lazy : + ?caching:bool -> ?max_chunk_size:int -> 'a t -> 'a Restart.t (** Same as {!persistent}, but consumes the generator on demand (by chunks). This allows to make a restartable generator out of an ephemeral one, @@ -89,6 +91,16 @@ Optional parameters: see {!GenMList.of_gen_lazy}. @since 0.2.2 *) +val persistent_to_seq : 'a t -> 'a Seq.t +(** Same as {!persistent}, but returns a standard Seq. + @since 1.0 *) + +val persistent_lazy_to_seq : + ?caching:bool -> ?max_chunk_size:int -> + 'a t -> 'a Seq.t +(** Same as {!persistent_lazy}, but returns a standard Seq. + @since 1.0 *) + val peek : 'a t -> ('a * 'a option) t (** [peek g] transforms the generator [g] into a generator of [x, Some next] if [x] was followed by [next] in [g], or [x, None] if [x] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/genLabels_intf.ml new/ocaml-gen-1.0/src/genLabels_intf.ml --- old/ocaml-gen-0.5.3/src/genLabels_intf.ml 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/genLabels_intf.ml 2022-01-21 19:13:43.000000000 +0100 @@ -8,6 +8,7 @@ explicitely that they use ['a gen] (transient generators). *) type 'a gen = unit -> 'a option +type 'a iter = ('a -> unit) -> unit module type S = sig type 'a t @@ -360,5 +361,11 @@ val pp : ?start:string -> ?stop:string -> ?sep:string -> ?horizontal:bool -> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit (** Pretty print the content of the generator on a formatter. *) + + val of_seq : 'a Seq.t -> 'a t + (** @since 1.0 *) + + val to_iter : 'a t -> 'a iter + (** @since 1.0 *) end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/genMList.ml new/ocaml-gen-1.0/src/genMList.ml --- old/ocaml-gen-0.5.3/src/genMList.ml 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/genMList.ml 2022-01-21 19:13:43.000000000 +0100 @@ -4,6 +4,7 @@ (** {1 Efficient Mutable Lists} *) type 'a gen = unit -> 'a option +type 'a iter = ('a -> unit) -> unit type 'a clonable = < gen : 'a gen; (** Generator of values tied to this copy *) clone : 'a clonable; (** Clone the internal state *) @@ -117,6 +118,26 @@ in next +let to_seq l0 : _ Seq.t = + let rec next l i ()= + match !l with + | Nil -> Seq.Nil + | Cons1 (x, l') -> + Seq.Cons (x, next l' i) + | Cons (a,n,l') -> + if i = !n then ( + next l' 0 () + ) else ( + let y = a.(i) in + Seq.Cons (y, next l (i+1)) + ) + | Suspend gen -> + let node = _read_chunk l0 gen in + l := node; (* modify previous pointer *) + next l i () + in + next l0.start 0 + let to_clonable l : 'a clonable = let rec make node i = let cur = ref node and i = ref i in diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/genMList.mli new/ocaml-gen-1.0/src/genMList.mli --- old/ocaml-gen-0.5.3/src/genMList.mli 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/genMList.mli 2022-01-21 19:13:43.000000000 +0100 @@ -32,6 +32,7 @@ @since 0.2.3 *) type 'a gen = unit -> 'a option +type 'a iter = ('a -> unit) -> unit type 'a clonable = < gen : 'a gen; (** Generator of values tied to this copy *) clone : 'a clonable; (** Clone the internal state *) @@ -57,4 +58,8 @@ (** Iterate on the mlist. This function can be called many times without any problem, the mlist isn't consumable! *) +val to_seq : 'a t -> 'a Seq.t +(** Iterate on the mlist using the standard functional iterators. + @since 1.0 *) + val to_clonable : 'a t -> 'a clonable diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ocaml-gen-0.5.3/src/gen_intf.ml new/ocaml-gen-1.0/src/gen_intf.ml --- old/ocaml-gen-0.5.3/src/gen_intf.ml 2020-05-12 16:01:46.000000000 +0200 +++ new/ocaml-gen-1.0/src/gen_intf.ml 2022-01-21 19:13:43.000000000 +0100 @@ -8,6 +8,7 @@ explicitely that they use ['a gen] (transient generators). *) type 'a gen = unit -> 'a option +type 'a iter = ('a -> unit) -> unit module type S = sig type 'a t @@ -362,5 +363,11 @@ val pp : ?start:string -> ?stop:string -> ?sep:string -> ?horizontal:bool -> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a t -> unit (** Pretty print the content of the generator on a formatter. *) + + val of_seq : 'a Seq.t -> 'a t + (** @since 1.0 *) + + val to_iter : 'a t -> 'a iter + (** @since 1.0 *) end