package seqes

  1. Overview
  2. Docs

Signatures for all the functors exported afterwards. The documentation of this module also introduces some general concepts of the library. It is a recommended reading for all users of the library.

Common module signatures

This compilation unit gathers module signatures which are used in the rest of the library. Essentially, the rest of the library provides functors to generate modules with the signatures below.

The Seqes library provides functors to produce specialised variants of the Stdlib.Seq type where the forcing of an element involves a monad. E.g., considering an I/O cooperative scheduling monad à la Lwt or Async, which we denote with the type 'a io, you can use Seqes to produce the following type

type 'a t = unit -> 'a node io
and 'a node =
  | Nil
  | Cons of 'a * 'a t

In addition to specialised types, the library's functor produce an assortment of functions to operate on values of this type. The assortment of function is compatible with the Stdlib.Seq (except for the monad part). See examples/seqseq/seqseq.ml for a demonstration of this compatibility.

Familiarity with Stdlib.Seq is assumed.

module type SEQMON1TRAVERSORS = sig ... end
module type SEQMON1TRANSFORMERS = sig ... end
module type SEQMON1ALL = sig ... end

Monads

Different functors require different monads.

module type MONAD1 = sig ... end

Normal monad

module type GLUE1 = sig ... end

Mixed-monad operations

Common module signatures

This compilation unit gathers module signatures which are used in the rest of the library. Essentially, the rest of the library provides functors to generate modules with the signatures below.

The Seqes library provides functors to produce specialised variants of the Stdlib.Seq type where the forcing of an element involves a monad. E.g., considering an I/O cooperative scheduling monad à la Lwt or Async, which we denote with the type 'a io, you can use Seqes to produce the following type

type 'a t = unit -> 'a node io
and 'a node =
  | Nil
  | Cons of 'a * 'a t

In addition to specialised types, the library's functor produce an assortment of functions to operate on values of this type. The assortment of function is compatible with the Stdlib.Seq (except for the monad part). See examples/seqseq/seqseq.ml for a demonstration of this compatibility.

Familiarity with Stdlib.Seq is assumed.

Two type parameters

Some monad have two type parameters. E.g., the result monad is over the type ('a, 'e) result.

The Seqes library offers all the same features over those monads than it does over the single-parameter monads. Accordingly, below are variants of the module signatures from Sigs1, but for two-parameter monads.

Note that the specialised type of sequence also carries these two parameters:

type ('a, 'e) t = unit -> (('a, 'e) node, 'e) io
and ('a, 'e) node =
  | Nil
  | Cons of 'a * ('a, 'e) t

See examples/seqres/seqres.ml for an example of using Seqes for the result monad. See examples/seqlwtres/seqlwtres.ml for an example of using Seqes for the Lwt+result monad.

Asymmetry

Note that the two type parameters of the monad are not treated the same. Seqes only requires a bind for the first parameter but not the second.

val bind : ('a, 'e) t -> ('a -> ('b, 'e) t) -> ('b, 'e) t
module type SEQMON2TRAVERSORS = sig ... end

Equivalent to Sigs1.SEQMON1TRAVERSORS but with two type parameters.

module type SEQMON2TRANSFORMERS = sig ... end

Equivalent to Sigs1.SEQMON1TRANSFORMERS but with two type parameters.

module type SEQMON2ALL = sig ... end

Equivalent to Sigs1.SEQMON1ALL but with two type parameters.

module type MONAD2 = sig ... end

Equivalent to Sigs1.MONAD but with two type parameters.

module type GLUE2 = sig ... end

Mixed-monad operations