A lightweight, modular standard library extension, string library, and interfaces to various libraries (unix, threads, etc.) BSD license.
Find a file
2014-06-24 16:23:30 +02:00
cgi remove generated files 2014-05-21 00:20:12 +02:00
core monadic combinators for lists and klists 2014-06-24 16:23:30 +02:00
examples cosmetic details on trees 2014-06-16 21:15:05 +02:00
lwt remove generated files 2014-05-21 00:20:12 +02:00
misc cosmetic details on trees 2014-06-16 21:15:05 +02:00
string update the klist type in other modules 2014-05-26 22:01:21 +02:00
tests fix tests 2014-06-15 23:50:28 +02:00
threads remove generated files 2014-05-21 00:20:12 +02:00
.gitignore qtest 2014-05-12 15:30:13 +02:00
.header Cause: debugging experiment, tracking why values exist and actions were performed 2014-04-23 17:59:43 +02:00
.merlin enable warnings 2014-05-17 00:59:07 +02:00
.ocamlinit misc/PrintBox: printing of nested box into ascii 2014-06-15 22:34:09 +02:00
_oasis random generators in several modules, and CCRandom to bind them all with fuel 2014-06-24 14:06:48 +02:00
_tags enable warnings 2014-05-17 00:59:07 +02:00
configure moved cgi in a subdir (would not build with oasis 0.4 otherwise) 2013-12-30 12:20:05 +01:00
LICENSE gitignore and update of readme; added LICENSE file (BSD) 2013-02-27 16:12:14 +01:00
Makefile build doc for containers_string; fix upload of docs 2014-06-16 00:36:55 +02:00
META moved futures into threads/ and updated oasis; added benchmark for Conv 2014-03-01 16:30:52 +01:00
README.md update readme 2014-05-26 19:09:06 +02:00
setup.ml moved some files into lwt/ subdir; 2014-05-12 15:23:54 +02:00

ocaml-containers

A bunch of modules I wrote mostly for fun. It is currently divided into a few parts:

  1. A usable, reasonably well-designed library that extends OCaml's standard library (in core/, packaged under containers in ocamlfind. Modules are totally independent and are prefixed with CC (for "containers-core" or "companion-cube" because I'm megalomaniac). This part should be usable and should work. For instance, CCList contains functions and lists including safe versions of map and append.
  2. A satellite library, containers.string (in directory string) with a few packed modules that deal with strings (Levenshtein distance, KMP search algorithm, and a few naive utils). Again, modules are independent and sometimes parametric on the string and char types (so they should be able to deal with your favorite unicode library).
  3. Random stuff, with NO GUARANTEE of even being barely usable or tested, in other dirs (mostly misc but also lwt and threads). It's where I tend to write code when I want to test some idea, so half the modules (at least) are unfinished or don't really work.

Some of the modules have been moved to their own repository (e.g. sequence, gen, qcheck and are on opam for great fun and profit (or not)).

Use

You can either build and install the library (see Build), or just copy files to your own project. The last solution has the benefits that you don't have additional dependencies nor build complications (and it may enable more inlining). Since modules have a friendly license and are mostly independent, both options are easy.

If you have comments, requests, or bugfixes, please share them! :-)

License

This code is free, under the BSD license.

Documentation

The API documentation can be found here.

Contents

The design is mostly centered around polymorphism rather than functors. Such structures comprise (some modules in misc/, some other in core/):

Core Structures

  • CCLeftistheap, a polymorphic heap structure.
  • CCFQueue, a purely functional queue structure
  • CCBV, mutable bitvectors
  • CCPersistentHashtbl, a semi-persistent hashtable (similar to persistent arrays)
  • CCVector, a growable array (pure OCaml, no C)
  • CCGen and CCSequence, generic iterators structures (with structural types so they can be defined in several places). Now also in their own repository and opam packages (gen and sequence).
  • CCKlist, another iterator structure
  • CCList, functions and lists including tail-recursive implementations of map and append
  • CCArray, utilities on arrays
  • CCInt, CCPair, CCOpt, CCFun, CCBool, utilities on basic types
  • CCPrint, printing combinators
  • CCHash, hashing combinators

Misc

  • PHashtbl, a polymorphic hashtable (with open addressing)
  • SplayTree, a polymorphic splay heap implementation (not quite finished)
  • SplayMap, a polymorphic functional map based on splay trees
  • Heap, an imperative heap based on SplayTree
  • Graph, a polymorphic imperative directed graph (on top of PHashtbl)
  • Hashset, a polymorphic imperative set on top of PHashtbl
  • LazyGraph, a lazy graph structure on arbitrary (hashable+eq) types, with basic graph functions that work even on infinite graphs, and printing to DOT.
  • Heap, a purely functional polymorphic heap
  • Bij, a GADT-based bijection language used to serialize/deserialize your data structures
  • RAL, a random-access list structure, with O(1) cons/hd/tl and O(ln(n)) access to elements by their index.
  • SmallSet, a sorted list implementation behaving like a set.
  • AbsSet, an abstract Set data structure, a bit like LazyGraph.
  • Univ, a universal type encoding with affectation
  • Cache, a low level memoization cache for unary and binary functions
  • Deque, an imperative double ended FIFO (double-linked list)
  • FlatHashtbl, a (deprecated) open addressing hashtable with a functorial interface (replaced by PHashtbl)
  • UnionFind, a functorial imperative Union-Find structure.

Others

  • Future, a set of tools for preemptive threading, including a thread pool, monadic futures, and MVars (concurrent boxes)

Some serialisation formats are also implemented, with a streaming, non-blocking interface that allows the user to feed the input in chunk by chunk (useful in combination with Lwt/Async). Currently, the modules are:

There is a QuickCheck-like library called QCheck (now in its own repo).

Build

There are no dependencies (Sequence is included). The Bij module requires OCaml >= 4.00 because of GADTs. Type:

$ make

To build and run tests (requires oUnit and qtest):

$ opam install oUnit
$ make tests
$ ./tests.native

and

$ opam install qtest
$ make qtest

To build the small benchmarking suite (requires benchmark):

$ opam install benchmark
$ make bench
$ ./benchs.native