package travesty

  1. Overview
  2. Docs
Module type
Class type


Travesty is a library for defining containers with monadic and otherwise 'exotic' traversals, inspired by Haskell's Traversable and related typeclasses. It sits on top of Jane Street's Core library ecosystem.

As well as monadic traversals, Travesty includes various other extensions on top of Core. These focus on making a more 'purely functional', Haskell-esque style of programming easier, though with a focus on pragmatism over mathematical purity.

Traversal interfaces

Travesty contains module signatures, functors, and extensions for dealing with various kinds of traversability:

Haskell's foldable functors already exist in Base as Container.

State monads

Travesty also contains implementations of state monads (State) and transformers (State_transform). We use these to implement fold-mapping and folding on top of Traversable, but expose them for general consumption.


Travesty also contains extensions to various module signatures, as well as to Base and Core_kernel container and monad modules. We keep the latter in sub-libraries of Travesty.

Signature expansions

These are in the Travesty library, and always have the suffix exts. Some Travesty signatures pull them in automatically.

Implementation expansions

These are in the Travesty_base_exts library (expanding the Base versions) and the Travesty_core_kernel_exts library (expanding the Core_kernel versions). Each usually has the same name as the module it extends (except `Alist`), but doesn't re-export that module. The intended mode of use is:

(* Base *)
open Base
module Tx = Travesty_base_Exts

(* Core_kernel *) 
open Core_kernel
module Tx = Travesty_core_kernel_exts

let example (foo : ('k, 'v) List.Assoc.t) =
  Tx.Alist.bi_map ~left:foo ~right:bar foo

Custom containers

As well as expanding various Core and Core_kernel containers, Travesty features some of its own. These have various traversal and mapping features built in, but aren't necessarily optimised for heavy-duty use.

Each is in the Travesty_containers subpackage (in Dune, use travesty.containers.)

  • Singleton: treating a single data item like a mappable, traversable container
  • Zipper: list zippers
Other similar libraries
  • The BAP monads library also contains implementations of monadic traversals, as well as several of Travesty's other extensions.
Projects depending on Travesty
  • act, a toolbox for automatic compiler testing.