@Drup and myself have the pleasure to announce the first release of Iter (née Sequence). Its version is 1.2, following Sequence 1.1. We renamed Sequence into Iter to remove some confusion with Seq (the stdlib’s iterator type).
Iter provides combinators to create, consume, and transform iterators of type ('a -> unit) -> unit; in other words, partially applied iter function such as Hashtbl.iter, List.iter, Array.iter, etc. It has a wealth of advanced combinators and performs very well even with nested flat_map, map, etc. A very simple example that manipulates a series of integers:
# #require "iter";;
# let p x = x mod 5 = 0 in
Iter.(1 -- 5_000
|> filter p
|> map (fun x -> x * x)
|> fold (+) 0);;
- : int = 8345837500
First, Sequence is still usable and the packages are still there, so migration isn’t urgent. That being said, I just migrated a project of mine by changing the dependency and sed -i s/Sequence/Iter src/**/*.ml{,i} and it worked directly.
Hi Simon,
do you intend to update Containers accordingly?
The latter features sequence type synonyms in all modules which, as far as I recall, should all the same be called iter now, right? Besides, you have of_seq functions that take a sequence and not a seq as an argument, they should be called of_iter.
(While I’m at it, it would be cool to extend Containers with a little more (additive) monadic/applicative stuff, such as guard, mplus, and >>; it’s so useful for “nondeterministic” monads.)
Yes, it’ll probably part of the effort to make containers ready for 4.08 (which breaks everything with its deprecation warnings, yay).
I do indeed plan to use {of,to}_iter in additon to existing {of,to}_seq. Contributions welcome.
Regarding the monadic stuff, where would it live? >> cannot work in a strict language, afaik, and for the rest you could open an issue so we can express your needs
I haven’t followed the deprecation stuff. Just saw some allusion to an “alert” in the changelog but I don’t know what it does… I may not see all the ins and outs but wouldn’t you want to remove {of,to}_seq all the way? As people will have to change the name Sequence with Iter, you can leverage this to force the change to iter everywhere. I mean, it seems the situation is ideal for this, as the old sequence package will not move away. Regarding contributing, skimming through the repo, it seems the change is already done, isn’t it?
I wouldn’t remove {of,to}_seq from containers immediately (not before 3.0 anyway), but adding all the {of,to}_iter to containers would be very helpful. There’s also work needed to support 4.08 (since tons of things are deprecated).