Module 'Stream' removed from 5.0 standard library?

I think that the general direction of the Stdlib w.r.t. the Seq module and conversion functions specifically has been towards encouraging the use of Seq as an intermediate representation, a go-between different data-structures.

let m = MyMap.of_seq (Array.to_seq a) in
…

For this use Seq is arguably better than list. Of course different use cases might have different needs and such, but in many cases Seq is better. E.g., if you are interrupted by a minor collection you promote much less memory to the major heap than in the case of a list.


Other uses of Seqs are of course different. There are major downsides to using Seqs over Lists.

  • Mixing with monads is more complicated. E.g., Lwt_list functions on the same exact lists as the Stdlib, but Lwt_seq needs a custom type to get the monad right there in the arrow.
  • Lack of pattern matching makes your code boilerplaty. E.g., | [] -> … | [x] -> … | x::y::rest -> … is so concise and readable.
  • etc.

But I think that w.r.t. the conversion functions, it is good that the API encourages you to use Seq as an intermediate representation in between two data-structures.

1 Like