Compare commits

...

5 commits

Author SHA1 Message Date
Simon Cruanes
a525d4902c
prepare for 1.9
Some checks failed
github pages / deploy (push) Has been cancelled
build / Build (push) Has been cancelled
2025-02-04 23:40:54 -05:00
Simon Cruanes
99fa66f1db
format 2025-02-04 23:40:54 -05:00
Simon Cruanes
21107dc7e7
fix warnings 2025-02-04 23:40:54 -05:00
Josh Berdine
cd2d47f268 Switch exceptions used for control flow from global to local
Signed-off-by: Josh Berdine <josh@berdine.net>
2025-02-04 23:22:22 -05:00
Simon Cruanes
f9c6c077c6
fix CI 2025-02-04 22:01:47 -05:00
8 changed files with 28 additions and 33 deletions

View file

@ -11,14 +11,7 @@ jobs:
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: ocaml/setup-ocaml@v2
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: '4.14.x'
allow-prerelease-opam: true

View file

@ -21,7 +21,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- uses: ocaml/setup-ocaml@v2
- uses: ocaml/setup-ocaml@v3
with:
ocaml-compiler: ${{ matrix.ocaml-compiler }}
allow-prerelease-opam: true

View file

@ -1,4 +1,4 @@
version = 0.24.1
version = 0.26.2
profile=conventional
margin=80
if-then-else=k-r

View file

@ -1,4 +1,10 @@
# 1.9
- Switch exceptions used for control flow from global to local
- Update Iter.ml to use mutable fields instead of refs (#44)
# 1.8
- add `Iter.map_while`

View file

@ -1,6 +1,6 @@
opam-version: "2.0"
name: "iter"
version: "1.8"
version: "1.9"
authors: ["Simon Cruanes" "Gabriel Radanne"]
maintainer: "simon.cruanes.2007@m4x.org"
license: "BSD-2-clause"

View file

@ -330,9 +330,8 @@ let sort ?(cmp = Stdlib.compare) seq =
let l = List.fast_sort cmp l in
fun k -> List.iter k l
exception Exit_sorted
let sorted ?(cmp = Stdlib.compare) seq =
let exception Exit_sorted in
let prev = ref None in
try
seq (fun x ->
@ -556,9 +555,8 @@ let diff (type a) ?(eq = ( = )) ?(hash = Hashtbl.hash) c1 c2 =
c2 (fun x -> Tbl.replace tbl x ());
fun yield -> c1 (fun x -> if not (Tbl.mem tbl x) then yield x)
exception Subset_exit
let subset (type a) ?(eq = ( = )) ?(hash = Hashtbl.hash) c1 c2 =
let exception Subset_exit in
let module Tbl = Hashtbl.Make (struct
type t = a
@ -630,9 +628,8 @@ let sumf seq : float =
sum := t);
!sum
exception ExitHead
let head seq =
let exception ExitHead in
let r = ref None in
try
seq (fun x ->
@ -646,9 +643,8 @@ let head_exn seq =
| None -> invalid_arg "Iter.head_exn"
| Some x -> x
exception ExitTake
let take n seq k =
let exception ExitTake in
let count = ref 0 in
try
seq (fun x ->
@ -657,9 +653,8 @@ let take n seq k =
k x)
with ExitTake -> ()
exception ExitTakeWhile
let take_while p seq k =
let exception ExitTakeWhile in
try
seq (fun x ->
if p x then
@ -668,8 +663,6 @@ let take_while p seq k =
raise_notrace ExitTakeWhile)
with ExitTakeWhile -> ()
exception ExitFoldWhile
let map_while f seq k =
let exception ExitMapWhile in
let consume x =
@ -683,6 +676,7 @@ let map_while f seq k =
try seq consume with ExitMapWhile -> ()
let fold_while f s seq =
let exception ExitFoldWhile in
let state = ref s in
let consume x =
let acc, cont = f !state x in
@ -721,18 +715,16 @@ let rev seq =
let l = MList.of_iter seq in
fun k -> MList.iter_rev k l
exception ExitForall
let for_all p seq =
let exception ExitForall in
try
seq (fun x -> if not (p x) then raise_notrace ExitForall);
true
with ExitForall -> false
exception ExitExists
(** Exists there some element satisfying the predicate? *)
let exists p seq =
let exception ExitExists in
try
seq (fun x -> if p x then raise_notrace ExitExists);
false
@ -740,9 +732,8 @@ let exists p seq =
let mem ?(eq = ( = )) x seq = exists (eq x) seq
exception ExitFind
let find_map f seq =
let exception ExitFind in
let r = ref None in
(try
seq (fun x ->
@ -757,6 +748,7 @@ let find_map f seq =
let find = find_map
let find_mapi f seq =
let exception ExitFind in
let i = ref 0 in
let r = ref None in
(try
@ -790,9 +782,8 @@ let[@inline] length seq =
seq (fun _ -> incr r);
!r
exception ExitIsEmpty
let is_empty seq =
let exception ExitIsEmpty in
try
seq (fun _ -> raise_notrace ExitIsEmpty);
true
@ -1040,9 +1031,14 @@ module Map = struct
let of_iter_ seq = fold (fun m (k, v) -> M.add k v m) M.empty seq
let keys m = from_iter (fun k -> M.iter (fun x _ -> k x) m)
let values m = from_iter (fun k -> M.iter (fun _ y -> k y) m)
[@@@ocaml.warning "-32"]
let of_list l = of_iter_ (of_list l)
let to_list x = to_list (to_iter_ x)
[@@@ocaml.warning "+32"]
include M
let to_iter = to_iter_

View file

@ -22,4 +22,4 @@ let mmap filename yield =
with e ->
Unix.close fd;
raise e
[@@ocaml.warning "-3"]
[@@ocaml.warning "-3"]

View file

@ -3,7 +3,7 @@
(public_name iter)
(wrapped false)
(modules Iter IterLabels)
(flags :standard -w +a -warn-error -a+8 -nolabels))
(flags :standard -w +a-4 -warn-error -a+8 -nolabels))
(env
(_