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.
Travesty contains module signatures, functors, and extensions for dealing with various kinds of traversability:
Travesty.Mappable: mapping (in Haskell, functors);Travesty.Traversable: monadic traversal (in Haskell, traversable functors);Travesty.Bi_mappable: mapping on two types over the same container (in Haskell, bifunctors);Travesty.Filter_mappable: mapping that can discard elements (similar to the filtrable Haskell library).Haskell's foldable functors already exist in Base as Container.
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.
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.
These are in the Travesty library, and always have the suffix exts. Some Travesty signatures pull them in automatically.
Travesty.Container_exts)Travesty.Monad_exts)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 fooTravesty_base_exts.Tuple2: pairs/2-tuplesTravesty_base_exts.Alist: associative listsTravesty_base_exts.Or_error: error monadTravesty_base_exts.Fn: function combinatorsTravesty_base_exts.List: listsTravesty_base_exts.Option: optionsAs 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.)
Travesty_containers.Singleton: treating a single data item like a mappable, traversable containerTravesty_containers.Zipper: list zippersTravesty's other extensions.