package seqes

  1. Overview
  2. Docs

Module Seqes.MonadicSource

Functors to generate specialised monadic variants of the Stdlib.Seq.t type along with all the traversor and transformer functions.

Monad functors over Stdlib Sequences

Stdlib.Seq provides an abstraction for delayed lists. One limitation of the Stdlib.Seq module is that its type cannot accommodate monads. For example, considering a cooperative I/O monad in the style of Async or Lwt, using the type 'a io to denote promises of 'a, one cannot write

  val map_io : ('a -> 'b io) -> 'a Seq.t -> 'b Seq.t

That's because the Seq.t type includes an arrow (->) that is outside of the monad, as per the type declaration.

This here module exposes a Make functor which produces new Seq-like modules with a baked-in monad.

Recommended readings:

  • Familiarity with Stdlib.Seq is assumed.
  • See Sigs1 for an explanation of the separation of Traversors, Transformers, and the rest.
Sourcemodule type S1 = sig ... end

The module type for the output of the Make module (below).

Sourcemodule Make1 (Mon : sig ... end) : sig ... end

Make a specialised Seq-like module based on a given Monad.

Sourcemodule type S2 = sig ... end

The module type for the output of the Make2 module (below).

Sourcemodule Make2 (Mon : sig ... end) : sig ... end
OCaml

Innovation. Community. Security.