package travesty

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

Travesty

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 (Travesty.State) and transformers (Travesty.State_transform). We use these to implement fold-mapping and folding on top of Travesty.Traversable, but expose them for general consumption.

Extensions

Travesty also contains extensions to various module signatures, as well as to Base 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. 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:

open Base
module Tx = Travesty_base_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 Base 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.)

Other similar libraries
  • The BAP monads library also contains implementations of monadic traversals, as well as several of Travesty's other extensions.
  • The accessor library is an implementation of the related Haskell notion of 'lenses', composable accessors for nested functional data structures.
Projects depending on Travesty
  • act, a toolbox for automatic compiler testing.
OCaml

Innovation. Community. Security.