package batteries

  1. Overview
  2. Docs
Module type
Class type

OCaml Batteries Included documentation.

OCaml Batteries included (or simply "Batteries") is a community-driven effort to standardize on an consistent, documented, and comprehensive development platform for the OCaml programming language.

For the moment, Batteries Included concentrates on:

  • data structures
  • file manipulation
  • inputs and outputs
  • concurrency
  • numbers
  • text, including Unicode

For more information on the installation of Batteries Included, please read the Installation guide and for an example using it in different build systems, we have the Getting started manual.

Modules listed below can also be referenced as Batteries.<short name>--where <short name> is the module name without the initial "Bat"--or as <short name> alone, if Batteries has been opened. For example, BatLazyList can also be used as Batteries.LazyList, or as LazyList after executing open Batteries.

Do you have suggestions? Remarks? Bug reports ? To contact us or to be kept informed, don't hesitate to visit our website, Git repo, and our Issue tracker.

New Data Structures in Batteries
  • BatBitSet Efficient bit sets.
  • BatCache
  • BatDeque Functional double-ended queues
  • BatDllist A mutable, imperative, circular, doubly linked list library
  • BatDynArray Dynamic arrays.
  • BatEnum Enumeration over abstract collection of elements.
  • BatFingerTree This module implements a generic finger tree datastructure as described here: Finger Trees: A Simple General-purpose Data Structure
  • BatGlobal Mutable global variable.
  • BatHashcons Hash consing of data structures
  • BatHeap Functional heaps over ordered types
  • BatIMap DIET Maps from integers, packed using ranges
  • BatISet DIET : Discrete Interval Encoding Trees
  • BatLazyList Lazy lists of elements.
  • BatMultiPMap Polymorphic Multi-Map.
  • BatRefList Reference on lists.
  • BatSeq Sequence of elements
  • BatSplay Maps over ordered types based on splay trees.
  • BatText Heavyweight strings ("ropes")
  • BatUChar Unicode characters.
  • BatUref Unifiable references using destructive union-find
  • BatUTF8 UTF-8 encoded Unicode strings. The type is normal string.
  • BatVect Extensible vectors with constant-time append/prepend.
New Modules in Batteries
Builtin Types as Modules
Extensions to the Standard Library

These modules have base library equivalents. When using open Batteries, BatFoo will replace Foo, so that the new functions are easily available without a Bat prefix on the module name. As well, BatPervasives is opened into the global namespace. Finally, the previous versions of replaced modules are available in the Legacy module, i.e. Legacy.Unix and Legacy.Pervasives.

These modules are available only when compiling with threads. To use them, do open BatteriesThread at the top of your code.


These modules are available only inside Batteries.Incubator. Their interface is not guaranteed stable, and may be changed at any time, including with backwards incompatible changes between point releases. They are included for testing and stabilization until they can be finalized and moved to batteries proper.

Internal Modules
  • BatAvlTree Internals of ISet and IMap, usable as generic tree library
  • BatInnerIO Core of the BatIO module.
  • BatInnerWeaktbl Weak hash table library for OCaml, with an interface compatible with the standard Hashtbl module.