package monads

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

Container interface in the Kleisli category.

The module provides two interfaces for collections (containters) where functions return monadic computations instead of values.

As usuall, two interfaces are provided:

The container interfaces can be derived for any collection that implements a base interface. In our case we have two versions of the base interfaces, Eager and Delay. The interfaces differ only in the type of the fold function. The Eager interface provides a regular fold function, while the Delay.fold is a more general variant of fold that is parametrized by a continuation.

If it is not possible to provide the generic version of fold, then all iterators will be implemented using continuations, (i.e., will use a constant stack size). However, the iterators that maybe short circuited (i.e., a computation may be determined without consulting all the elements), e.g., find, exists, etc, will still still fold through all the elements. This is especially problematic with infinite sequences. So if it is possible the delayed version of fold should be provided, especially in the case of infinite sequences.

module type Basic = sig ... end

Base signature for collections

module type Eager = sig ... end

A container with an eager (regular) fold.

module type Delay = sig ... end

A container with a generic fold

module type S2 = sig ... end

A container interface for a binary monad.

module type S = sig ... end

A container interface for an unary monad

OCaml

Innovation. Community. Security.