Awesome OCaml
Everything youβll ever need on the road to mastering OCaml.
A curated list of references to awesome OCaml tools, frameworks, libraries
and articles. Additionally there is a collection of freely available
books,
papers
and
presentations.
If youβre looking for comprehensive community-driven content about OCaml
visit πOCamlverse!
For a quick introduction to the modern OCaml development workflow consult
the
Up and Running with OCaml
tutorial.
Your favorite package is not listed? Fork and
create a Pull Request
to add it!
Contents
Algorithms and Data Structures
Application Libraries
-
Batteries Included
β A community-maintained foundation library for your OCaml projects.
-
Cmdliner β
Declarative definition of command line interfaces for OCaml.
-
Core β Jane Street
Capitalβs full-fledged standard library overlay. A portable subset of
Core is also available:
Core_kernel.
-
Base - Jane Street
Capitalβs dependency-free, quick-compiling, fully-portable across any
environment that can run OCaml code standard library.
-
React β React is an
OCaml module for functional reactive programming (FRP). It provides
support to program with time varying values: declarative events and
signals.
-
Minicli β Minimalist
library for command line parsing.
-
easy-format β
Pretty-printing library for OCaml.
-
ocaml-rpc β Light
library to deal with RPCs in OCaml.
-
ocaml-containers
β A lightweight, modular standard library extension, string library and
interfaces to various libraries (bigarrays, unix, etcβ¦). BSD license.
Benchmarking
-
core_bench β
Micro-benchmarking library for OCaml by Jane Street.
-
benchmark β
Benchmarking functions for measuring the run-time of functions using
latency or throughput.
Blogs
Books
-
More OCaml: Algorithms, Methods, and Diversions
β In More OCaml John Whitington takes a meandering tour of functional
programming with OCaml, introducing various language features and
describing some classic algorithms. The book ends with a large worked
example dealing with the production of PDF files. There are questions
for each chapter together with worked answers and hints.
-
How to Think Like a (Functional) Programmer
by Allen Downey and Nicholas Monje β How to Think Like a Computer
Scientist is an introductory programming textbook based on the OCaml
language. It is a modified version of Think Python by Allen Downey. It
is intended for newcomers to programming and also those who know some
programming but want to learn programming in the function-oriented
paradigm, or those who simply want to learn OCaml.
-
OCaml from the Very Beginning by J.
Whitington - OCaml from the Very Beginning will appeal both to new
programmers, and experienced programmers eager to explore functional
languages such as OCaml.
-
Pearls of Functional Algorithm Design
by Richard Bird - It summaries 30 hard algorithm problems in function
programming world. Although it is for Haskell, the algorithm problems
are very interesting and trying to solve them in OCaml also helps the
thinking of functional programming. Partial solutions in OCaml are
here.
-
Real World OCaml by Y. Minsky,
A. Madhavapeddy and J. Hickey - Functional programming for the masses.
-
Unix System Programming in OCaml
by X. Leroy and D. RΓ©my β Introduction to Unix system programming, with
an emphasis on communications between processes.
-
Using, Understanding, and Unraveling OCaml
β This book describes both the OCaml language and the theoretical
grounds behind its powerful type system.
-
Purely Functional Data Structures
- This is the first or only book focus on various data structures in FP
world. A must-read one.
-
OCaml for Scientists
- by Jon Harrop.
-
Functional Programming in OCaml: A Principled Approach
- Textbook for CS 3110 Functional Programming in OCaml, Cornell
University.
Code Analysis and Linters
-
Mascot - Mascot is a style-checker
for OCaml sources
-
pfff β pfff is a set
of tools and APIs to perform some static analysis, dynamic analysis,
code visualizations, code navigations, or style-preserving
source-to-source transformations such as refactorings on source code.
-
Infer - Infer is a
static analyzer for Java, C and Objective-C
-
Frama-C - Frama-C is a static analysis
and formal proof framework for C and C++
-
flow - flow is a static
type checker for JavaScript
-
SLAyer - SLAyer is an
automatic formal verification tool that uses separation logic to verify
memory safety of C programs.
-
MemCAD - MemCAD is
an abstract interpreter for shape analysis. MemCAD can verify C programs
manipulating complex data structures.
-
Camelot - Camelot
is a modular and fully configurable OCaml linter and stylechecker.
Program analysis
-
BAP - BAP is
a reverse engineering and program analysis platform that targets binary
programs.
-
BinCat - BinCat is
a binary code static analysis toolkit.
-
cwe_checker -
cwe_checker finds vulnerable patterns in binary executables.
-
Languages and Compilers:
-
Parser and Lexer Generators:
-
Opal β
Self-contained monadic parser combinators for OCaml.
-
Sedlex is a
modern, encoding-agnostic (read: Unicode-supporting) lexer generator
(the ppx-based successor to
ulex.)
-
Menhir β
Menhir is a LR(1) parser generator for OCaml.
-
See
ocaml-parsing
for a clearer example of using Menhir and Sedlex to produce a
useful parser,
-
β¦ and
Obelisk, a
neat project to produce readable LaTeX, HTML, or plain-text
EBNF-style documentation for your grammar.
-
ocamllex/ocamlyacc
β lex and yacc implementation for OCaml.
-
Angstrom -
Parser combinators built for speed and memory efficiency
-
Articles:
Concurrency
Two concurrency libraries exist in OCaml: Lwt and Async.
They provide very similar functionality but make radically different
decisions with regards to error handling and internal implementation
details (see the links below for more details).
Real World OCaml uses Async but
a version of the
code examples translated to Lwt
is also available.
-
Libraries:
-
Lwt β A cooperative threads
library for OCaml.
-
Async β A
monadic concurrence library to go with the Core library.
-
Articles:
There is also an ongoing experimental project to make OCaml multiprocessor
and multicore aware at
OCaml multicore
fork.
Databases
-
Bindings
-
Dbm β A
binding to the NDBM/GDBM Unix βdatabasesβ.
-
Mongo.ml β An OCaml
driver for Mongodb
-
PGβOCaml β A
type-safe interface to PostgreSQL in pure OCaml.
-
ppx_pgsql β A
syntax extension for embedded SQL queries using PGβOCaml.
-
PostgreSQL-OCaml
β An interface to PostgreSQL through the C API (
libpq
).
-
SQLite3 β
OCaml bindings to the SQLite3 database.
-
Sqlite3EZ β
Thin wrapper for SQLite3 with a simplified interface.
-
ocaml-redis β
Redis bindings for OCaml.
-
mysql β Bindings to
libmysqlclient for interacting with MySQL databases.
-
pgx β A pure OCaml
PostgreSQL client library .
-
mysql_protocol
β Implementation of MySQL Protocol with the Bitstring library.
-
New Implementations
-
Irmin β A distributed
database that follows the same design principles as Git.
-
Obigstore β A
database with BigTable-like data model atop LevelDB.
-
RunOrg - It is a WIP
database server written in OCaml.
-
dokeysto - dumb
OCaml key-value store, string keys and string values. Optional
on-the-fly LZ4 compression of values or tokyocabinet backend.
-
Overlays
-
Sequoia - Sequoia
is a type-safe query builder for MySQL/MariaDB and PostgreSQL
-
Macaque β Macaque
is a library for safe and flexible database queries using
comprehensions on top of PGβOCaml.
-
ORM β ORM for SQLite.
-
Caqti -
Cooperative-threaded access to relational data
-
Articles:
Datetime
Exercises and Short Examples
-
Coq β Coq is a formal proof
management system. It provides a formal language to write mathematical
definitions, executable algorithms and theorems together with an
environment for semi-interactive development of machine-checked proofs.
-
Why3 β Why3 is a platform for
deductive program verification. It provides a rich language for
specification and programming, called WhyML, and relies on external
theorem provers, both automated and interactive, to discharge
verification conditions.
-
Alt-Ergo β Alt-Ergo is an
open-source SMT solver dedicated to the proof of mathematical formulas
generated in the context of program verification.
General
Graphics
-
2D
-
archimedes β 2D
plotting library.
-
cairo2 β
Binding to Cairo, a 2D Vector Graphics Library. Integrates well with
lablgtk.
-
Vg β Declarative 2D
vector graphics for OCaml.
-
3D
-
glMLite β OpenGL
bindings for OCaml. Provides an (experimental) functional API. (homepage)
-
lablgl β
Interface to OpenGL. Integrates well with lablgtk.
-
tgls β Thin bindings
OpenGL 3.{2,3},4.{0,1,2,3,4} and OpenGL ES {2,3}.
Internationalization
-
Camomile β A Unicode
library for OCaml.
-
ocaml-m17n β
Multilingualization for OCaml source code. Allows using Unicode
identifiers in OCaml source code.
-
Uucd β Unicode character
database decoder for OCaml.
-
Uucp β Unicode character
properties for OCaml.
-
Uunf β Unicode text
normalization for OCaml.
-
Uuseg β Unicode text
segmentation for OCaml.
-
Uutf β Non-blocking
streaming Unicode codec for OCaml.
User Interface
-
lablgtk β GTK2 and
GTK3 bindings for OCaml with various higher-level facilities to define
GUIs.
-
lablqml β QML Qt5
bindings for OCaml.
-
labltk β
Interface to the Tcl/Tk GUI framework. In the standard distribution for
ocaml <= 4.01.
-
TSDL β Tsdl is an OCaml
module providing thin bindings to the cross-platform SDL library.
-
Lambda-Term
β Lambda-Term is a cross-platform library for manipulating the terminal.
It provides an abstraction for keys, mouse events, colors, as well as a
set of widgets to write curses-like applications.
-
Notty - Notty is a
declarative terminal library for OCaml, structured around a notion of
composable images.
-
ocaml-linenoise
- Self-contained OCaml bindings to linenoise, easy high level readline
functionality in OCaml.
Large Source Code Examples
-
Base - Standard library
for OCaml
-
cil - C Intermediate
Language
-
coq - formal proof management
system
-
Dark - a combined
language, editor, and infrastructure to make it easy to build backends
-
frama-c - platform
dedicated to the analysis of source code written in C
-
libguestfs -
library and tools for accessing and modifying virtual machine disk
images
-
Liquidsoap - a
swiss-army knife for multimedia streaming, notably used for netradios
and webtvs
-
mirage - library
operating system that constructs unikernels for secure, high-performance
network applications across a variety of cloud computing and mobile
platforms
-
MLDonkey -
cross-platform multi-network peer-to-peer daemon
-
Oni2 - Native, lightweight
modal code editor
-
pfff - an OCaml API
to write static analysis, dynamic analysis, code visualizations, code
navigations, or style-preserving source-to-source transformations such
as refactorings on source code.
-
WHY3 - platform for
deductive program verification
-
xen-api -
management stack that configures and controls Xen-enabled hosts and
resource pools, and co-ordinates resources within the pool
Logging
-
dolog β A dumb OCaml
logger.
-
Volt β A variant of Bolt
OCaml logging tool.
-
Logs - Logs provides a
logging infrastructure for OCaml.
Machine Learning
Messaging
-
ocaml-zmq β ZeroMQ
bindings for OCaml with Async and Lwt wrappers.
-
onanomsg β nanomsg
bindings for OCaml.
-
Kafka β OCaml
bindings for Apache Kafka.
-
AMQP β AMQP
client library for Async and Lwt.
-
MPI β Message
Passing Interface bindings for OCaml.
-
MQTT β OCaml
implementation of the MQTT pubsub protocol.
-
capnp-ocaml β
OCaml code generator plugin for the Capβn Proto serialization framework.
-
Articles:
-
Syntax Extensions:
-
ppx_import β
Import is a syntax extension that allows to pull in types or
signatures from other compiled interface files.
-
ppx_string_interpolate
β A simple ppx filter to support string interpolation like
[%str "value of foo is $(foo)"]
.
-
ppx_monad β Monad
syntax extension for OCaml.
-
ppx_deriving_yojson
β A Yojson codec generator for OCaml.
-
Tools and Language Extensions:
-
MetaOCaml β an
OCaml dialect for multi-stage programming.
-
Fan β Fan is a compile-time
metaprogramming system for OCaml, originally inspired from Camlp4.
Itβs a combination of OCaml and Lispy Macros. It shares the same
concrete syntax with OCaml.
-
camlp5 - Camlp5 is a
preprocessor-pretty-printer of OCaml.
-
camlp4
- Camlp4 is part of the standard OCaml distribution and is different
from Camlp5.
Metrics
-
prometheus β OCaml
client library for Prometheus monitoring.
Mobile Applications
-
Articles:
-
Bindings:
-
Cordova plugins
β List of bindings to Cordova plugins. Get access to native device
components like accelerometer, SMS, geolocation, etc in OCaml.
Networking
-
HTTP Tools:
-
ocaml-cohttp β
Very lightweight HTTP server using Lwt or Async.
-
ocurl β OCaml bindings
to libcurl.
-
httpaf β A
high performance, memory efficient, and scalable web server written
in OCaml.
-
piaf -
Client/server library for HTTP/1.X / HTTP/2 written entirely in
OCaml.
-
ocaml-dns β A pure
OCaml implementation of the DNS protocol.
-
fluent-logger
β Fluentd logger for OCaml.
-
charrua-unix -
charrua-unix is a Unix DHCP daemon based on
charrua-core.
Online Courses
Package Management
-
Distribution:
-
OPAM β A flexible
Git-friendly package manager with multiple compiler support.
-
ocamlfind
β Local OCaml library manager. Used by most of the OCaml ecosystem.
-
OCaml for Windows
- opam repository and experimental build for Windows.
-
makorel β Release
OPAM packages easily.
-
esy - package.json workflow
for native development with Reason/OCaml.
-
Build Tools:
-
dune β A composable and
opinionated build system for OCaml (former jbuilder)
-
Oasis - A tool to
integrate a configure, build and install system in your OCaml
project. It helps to create standard entry points in your build
system and allows external tools to analyse your project easily.
-
oasis2opam β
Tool to convert OASIS metadata to OPAM package descriptions.
-
obuild β Simple
package build system for ocaml.
-
ocaml-makefile
β Easy to use Makefile for small to medium-sized OCaml-projects.
-
topkg β OPAM-aware
packaging system using ocamlbuild.
-
Bazel - OCaml rules
for Bazel, Googleβs
multi-language and platform build tool.
Parallelism
(Note: Sorted from the easier to use to the more flexible.)
-
Libraries:
-
Parmap β Provides
easy-to-use parallel map and fold functions.
-
ForkWork β A simple
library for forking child processes to perform work on multiple
cores.
-
Functory β A
distributed computing library which facilitates distributed
execution of parallelizable computations in a seamless fashion.
-
Rpc.Parallel
β A library for spawning processes on a cluster of machines, and
passing typed messages between them.
-
Ocamlnet
β An enhanced system platform library. Contains the
netmulticore
library to compute tasks on as many cores
of the machine as needed.
-
Nproc β Process
pool implementation for OCaml.
-
Parany β
Parallelize computation over independent items, even if there is an
infinite number of them.
-
Sklml β Functional parallel
skeleton compiler and programming system for OCaml programs.
-
SPOC -
Libraries and syntax extensions to offload intensive computations to
parallel accelerators (multicore CPUs, GPUs and other accelerators
compatible with GPGPU frameworks).
-
Articles:
Project Starter Templates
-
drom - The drom tool is
a wrapper over opam/dune in an attempt to provide a cargo-like user
experience.
-
spin - Reason and Ocaml
project generator
-
modern-ocaml -
Template for an ocaml project with modern tooling
Questions
Science and Technical Computing
-
biocaml β OCaml
Bioinformatics Library
http://biocaml.org.
-
guizmin β OCaml library
for building bioinformatics pipelines.
-
lacaml - OCaml bindings
for BLAS/LAPACK (high-performance linear algebra Fortran libraries).
-
obandit - OCaml library
for multi-armed bandits.
-
onumerical β
Numerical library for OCaml.
-
oml - OCaml library for
general numerical work.
-
ocephes - Bindings to
frequently used
C
special functions library.
-
slap - A linear algebra
library in OCaml with type-based static size checking for matrix
operations.
-
tensorflow-ocaml
β OCaml bindings for TensorFlow.
-
owl - OCaml numerical
library: dense and sparse matrix, linear algebra, regressions, maths and
stats functions.
Regular Expressions
-
Re β a pure OCaml
regular expressions library with combinators, supporting several formats
(glob, posix, strβ¦)
-
ocaml-pcre β bindings
to the PCRE library (perl-compatible regular expressions)
-
Humane-re β
Humane-re attempts to provide an easy interface for 90% of your regex
needs Courtesy of ocaml-re
-
Tyre - Tyre is a set of
combinators to build type-safe regular expressions, allowing automatic
extraction and modification of matched groups.
Security and Cryptography
-
ocaml-tls β TLS in
pure OCaml.
-
Digestif - Hash
algorithms (like SHA* or BLAKE2*) in OCaml and C.
-
cryptokit β The
Cryptokit library for OCaml provides a variety of cryptographic
primitives that can be used to implement cryptographic protocols in
security-sensitive applications.
-
nocoiner - A
Commitment Schemes library for Multi-party Computations such as online
Auctions and Gambling.
-
nocrypto β A
small cryptographic library behind the ocaml-tls project. It is built to
be straightforward to use, adhere to functional programming principles
and able to run in a Xen-based unikernel.
Note: The differences between nocrypto
and
cryptokit
cryptographic libraries are described in the
following blog post:
OCaml-TLS: building the nocrypto library core.
Semantic Technology
-
OCaml-RDF β OCaml
library to manipulate RDF graphs and execute Sparql queries.
Serialization
-
bencode β Bencode
(.torrent file format) reader/writer.
-
biniou β Extensible
binary data format, like JSON but faster.
-
cbor β OCaml native
CBOR decoder/encoder.
-
jsonm β Non-blocking
streaming JSON codec for OCaml.
-
xmlm β A streaming codec
to decode and encode the XML data format.
-
yojson β An
optimized parsing and printing library for the JSON format.
-
sexplib β A
S-expression parser and printer
System Programming
Testing
-
Alcotest β A
lightweight and colourful test framework.
-
OUnit β OUnit is a unit
test framework for OCaml. It allows one to easily create unit-tests for
OCaml code. It is based on HUnit, a unit testing framework for Haskell.
-
QCheck β QCheck is a
property testing library inspired from Haskellβs QuickCheck
-
iTeML (formerly
known as qtest) β
supports inline pragmaβs to generate tests.
-
Kaputt β comprehensive testing
framework.
-
Pa_test
β General inline testing macroβs.
-
TestSimple - A
lightweight unit testing framework compatible with the
Test Anything Protocol.
-
expect-test β A
framework for writing tests in OCaml, similar to
Cram, developed by
JaneStreet.
Utilities
-
ocaml-cuid -
Collision-resistant IDs for server scalability & database
performance.
-
Uuidm - Uuidm is an
OCaml module implementing 128 bits universally unique identifiers
version 3, 5 (name based with MD5, SHA-1 hashing) and 4 (random based)
according to RFC 4122.
Web Development
-
Frameworks:
-
Opium β Sinatra
like web toolkit for OCaml.
-
Ocsigen Eliom β Eliom is a
full-featured multi-tier framework, for developing multi-platform
Web and mobile apps as 100% OCaml distributed applications. It can
also be used for more traditional Web or mobile apps: Web sites,
single page applications, REST API, etc.
-
Dream - Tidy Web
framework for OCaml and ReasonML
-
webmachine
β A REST toolkit for OCaml. OCaml webmachine is a layer on top of
cohttp that implements a state-machine-based HTTP request processor.
Itβs particularly well-suited for writing RESTful APIs. As the name
suggests, this is an OCaml port of the webmachine project.
-
incr_dom - A
library for building dynamic webapps, using Js_of_ocaml
-
ocaml-vdom - Elm
architecture and (V)DOM for OCaml
-
Tools:
-
COW β Caml on the
Web (COW) is a set of parsers and syntax extensions to let you
manipulate HTML, CSS, XML, JSON and Markdown directly from OCaml
code.
-
Ocamlnet
has many relevant web libraries β
Nethtml
html parser,
Netasn1
for ASN.1 parsing,
Netencoding
for Base64, Quoted Printable, URL encoding and HTML escaping,
Netmime
for MIME processing, etc. See the
list of modules
in Ocamlnetβs manual.
-
tyxml β Library to build
valid (according to the W3C spec) Html and Svg trees.
-
js_of_ocaml β
Js_of_ocaml is a compiler of OCaml bytecode to Javascript. It makes
it possible to run Ocaml programs in a Web browser.
-
commonjs_of_ocaml
- Easily import and export CommonJS modules from a js_of_ocaml
project.
-
ReScript - ReScript is a
robustly typed language that compiles to efficient and
human-readable JavaScript.
-
ocaml-uri β
RFC3986 URI parsing library.
-
Goji β An OCaml
bindings generator for JavaScript libraries.
-
Syndic β RSS and
Atom feed parsing
-
ocaml-mustache
β mustache.js logic-less templates in OCaml.
-
atdjs β atd code
generator for OCaml/js_of_ocaml.
-
jingoo β OCaml
template engine almost compatible with jinja2.
-
dispatch
β Path-based dispatching for client- and server-side applications.
-
Lambda Soup -
Functional HTML scraping and manipulation with CSS selectors, Γ la
Pythonβs Beautiful Soup.
-
Markup.ml -
Error-recovering streaming HTML5 and XML parsers, serializers.
-
gen_js_api -
gen_js_api aims at simplifying the creation of OCaml bindings for
Javascript libraries.
-
routes - Typed
routes for OCaml/ReasonML web applications.
-
Open Source Projects:
-
Cumulus β Hacker
news like website with the OCaml framework Ocsigen
Inspired by awesome projects line. Discover
more awesomeness
:sparkles:.