Batteries user guide

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:

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

The data structure for a manual cache with keys 'a and values 'b.

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 http://www.soi.city.ac.uk/~ross/papers/FingerTree.pdf

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 and sets based on splay trees

BatText

Heavyweight strings ("ropes")

BatUChar

Unicode characters.

BatUref

Unifiable references using destructive union-find

BatUTF8

UTF-8 encoded Unicode strings.

BatVect

Extensible vectors with constant-time append/prepend.

New Modules in Batteries

BatBase64

Base64 codec.

BatCharParser

Parsing character strings.

BatFile

File manipulation.

BatInterfaces

Common signatures for data structures.

BatIO

High-order abstract I/O.

BatLog

Simple logging

BatLogger

Logging Library

BatNumber

A common interface for numbers.

BatOptParse

Modules for GNU getopt(3)-style command line parsing.

BatParserCo

A simple parser combinator library.

BatResult

Monadic results of computations that can raise exceptions

BatReturn

Local exceptions/labels/goto/return.

Builtin Types as Modules

BatBool

Operations on booleans

BatChar

Operations on characters.

BatFloat

Operations on floating-point numbers.

BatInt

Operations on integers.

BatInt32

32-bit integers.

BatInt64

64-bit integers.

BatNativeint

Processor-native integers.

BatOption

Functions for the option type.

BatRef

Operations on references.

BatTuple

Tuples.

BatUnit

Operations on unit.

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.

BatArray

Array operations

BatBigarray

Additional and modified functions for big arrays.

BatBig_int

Operations on arbitrary-precision integers.

BatBuffer

Extensible string buffers.

BatComplex

Additional and modified functions for complex numbers.

BatDigest

MD5 message digest.

BatFormat
BatGc

Memory management control and statistics; finalised values.

BatGenlex

A generic lexical analyzer.

BatHashtbl

Extra functions over hashtables.

BatLexing

Simple lexing using ocaml conventions

BatList

Additional and modified functions for lists.

BatMap

Association tables over ordered types.

BatMarshal

Marshaling of data structures.

BatNum

Operation on arbitrary-precision numbers.

BatOo

Operations on objects

BatPervasives

Additional functions.

BatPrintexc

Facilities for printing exceptions.

BatPrintf
BatQueue

First-in first-out queues.

BatRandom

Pseudo-random number generators (PRNG).

BatScanf

Formatted input functions.

BatSet

Sets over ordered types.

BatStack

Last-in first-out stacks.

BatStream

Streams and stream parsers

BatString

String operations.

BatSys

System interface.

BatUnix

Thread-related Modules

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

BatConcurrent

Definition of concurrency primitives.

BatMutex

Locks for mutual exclusion.

BatRMutex

Reentrant Mutexes

Incubator

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.

BatBounded

Bounded values

BatOrd
BatPathGen

Filepath handling.

BatSubstring

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.