package travesty

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

The main groups of signatures provided by this module are:

  • Basicn: minimal definition of new modules without an existing Container instance;
  • Basicn _container: minimal definition of new modules with an existing Container instance;
  • Sn: full traversable containers, produced by applying functors to either of the two groups.

We also define other signatures, mostly for internal book-keeping. They may be useful elsewhere, however.

Inner-traversal signatures

These signatures form the inner body of the On functors in the main signatures. They all have names ending with _on_applicative or _on_monad, and assume the existence of a applicative functor or monad M.

While they aren't interesting on their own, they do contain (in slightly abstract form) the specific functions needed to build, and provided on building, traversable containers.

The generic signatures

As with Mappable, we define some signatures for traversable structures in an arity-generic way, then specialise them for arity-0 and arity-1 types.

module type Basic_generic_on_applicative = sig ... end

Basic_generic_on_applicative describes traversal on either an arity-0 or arity-1 type.

module type Generic_on_applicative = sig ... end

Generic_on_applicative extends Generic to contain various derived operators; we use it to derive the signatures of the various On_* modules.

module type Generic_on_monad = sig ... end

Generic_on_monad extends Generic_on_applicative to contain various derived operators that require monads; we use it to derive the signatures of the various On_monad modules.

Basic signatures
module type Basic0_on_applicative = sig ... end

Basic0_on_applicative is the inner signature of a traversal over arity-0 types.

module type Basic1_on_applicative = sig ... end

Basic1_on_applicative is the inner signature of a traversal over arity-1 types.

Expanded signatures
module type S1_on_applicative = sig ... end

S1_on_applicative extends Generic_on_applicative with functionality that only works on arity-1 containers.

module type S1_on_monad = sig ... end

S1_on_monad extends Generic_on_monad with functionality that only works on arity-1 containers.

Basic signatures

Any traversable type can be turned into a Base container, using the applicative fold to implement all container functionality. The unified signature of a container with traversals is S0 (arity 0) or S1 (arity 1).

To satisfy these signatures for new types, implement Basic0 or Basic1, and use the corresponding MakeN functor. Note that you must supply an On module in terms of applicatives, but not an On_monad module; previous versions of Travesty required the opposite.

For types that are _already_ Base containers, or types where custom implementation of the Base signature are desired, implement Basic0_container or Basic1_container, and use the MakeN_container functors.

For modules without a Container implementation
module type Basic0 = sig ... end

Basic0 is the minimal signature that traversable containers of arity 0 must implement to be extensible into S0.

module type Basic1 = sig ... end

Basic1 is the minimal signature that traversable containers of arity 1 must implement to be extensible into.

For modules with a Container implementation
module type Basic0_container = sig ... end

Basic0_container combines Basic0 and the Base container signature, and is used for extending existing containers into S0_containers.

module type Basic1_container = sig ... end

Basic1_container combines Basic1 and the Base container signature, and is used for extending existing containers into S1_container s.

Signatures for traversable containers

module type Generic = sig ... end

Generic is a generic interface for traversable containers, used to build S0 (arity-0) and S1 (arity-1).

module type S0 = sig ... end

S0 is a generic interface for arity-0 traversable containers.

module type S1 = sig ... end

S1 is a generic interface for arity-1 traversable containers. It also includes the extensions from Mappable.

OCaml

Innovation. Community. Security.