[ANN] Release of Seqes version 0.1


I am happy to announce the release of Seqes, a library to combine Seq and monads. The bulk of the initial development happened during the mirage-os retreat, with a few rounds of API design, test suite expansion, and documentation writing afterwards.

The package is released under LGPL with linking exception (it is based on code from the OCaml’s Stdlib).
The code is hosted on Gitlab.
It is available through opam: opam install seqes.

The library is fully usable and has a comprehensive QCheck-based test coverage, but the interface may change in the future (see follow-up thread with its typing puzzle).

Uses and examples

The Seq module does not mix well with monads. This is why in Lwt the Lwt_seq module defines its own Stdlib.Seq.t-like type — whereas the Lwt_list module simply defines some functions around the Stdlib.List.t type.

In addition, the Seq module has grown a lot between OCaml 4.13 and 4.14. This makes the maintenance of Seq-like modules (in the style of Lwt_seq) difficult.

The Seqes library addresses this by providing a functor to generate Lwt_seq-like modules but for any monad. There are two main functors,

Extending the Stdlib.Seq module:

module Seq
: sig

  (* The whole of the Seq module from Stdlib *)
  include module type of struct include Stdlib.Seq end

  (* Additional Lwt traversors *)
  module S : Seqes.Sigs.SEQMON1TRAVERSORS
    with type 'a mon := 'a Lwt.t
    with type 'a callermon := 'a Lwt.t
    with type 'a t := 'a Stdlib.Seq.t

= struct
  include Stdlib.Seq
  module S = Seqes.Standard.Make1(Lwt)

This extended module let’s you traverse the Stdlib sequences with Lwt functions.

Seq.exists Lwt_unix.file_exists filename_sequence

Making a new monad-friendly type

module SeqS
: sig

  (* Similar to [Stdlib.Seq] but with [Lwt] baked into the sequence type. *)
  include Seqes.Sigs.SEQMON1ALL
    with type 'a mon := 'a Lwt.t

  (* Additional Lwt helpers. E.g., [M.map : ('a -> 'b Lwt.t) -> 'a t -> 'b t]. *)
  module M :
      with type 'a mon := 'a Lwt.t
      with type 'a callermon := 'a Lwt.t
      with type 'a t := 'a t

= Seqes.Monadic.Make1(Lwt)

This module has its own Seq-like type but with the Lwt monad built-in.

type 'a t = unit -> 'a node Lwt.t