OCaml

repo: ocaml-community/awesome-ocaml
category: Programming Languages related: Functional Programming · Haskell


Awesome OCaml

<img src="colour-logo.png" width="70%" />

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


Community

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.
  • ReactReact is an OCaml module for functional reactive programming (FRP). It provides support for programs 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

Blogs

Books

Videos

- OCaml Programming: Correct + Efficient + Beautiful - List of 200 bite-sized videos recorded by Michael R. Clarkson. It can be watched independently of the textbook titled the same and listed above in the Books section.

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.
  • coq-of-ocaml - Translator from OCaml to Coq to formally verify OCaml code.
  • MOPSA - MOPSA is a generic framework for building sound static analyzers based on the theory of abstract interpretation.

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.
  • Owi - Owi is a toolchain for working with WebAssembly (Wasm) in OCaml, featuring a powerful, parallel symbolic execution engine for Wasm. It also provides frontends for compiling and analyzing C and Rust programs.
  • Smt.ml - Smt.ml is a frontend OCaml library that interfaces with multiple SMT solvers, enabling seamless integration of solvers like Z3, cvc5, Colibri2, Bitwuzla, and Alt-Ergo within OCaml programs.

Compilers and Compiler Tools

Concurrency

Before OCaml 5.0, there were two libraries for concurrent programming: 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.

With the introduction of Effect Handlers in OCaml 5.0, a bunch of other libraries have been created for concurrent programming, replacing the monadic approaches of LWT and Async with direct-style ones.

Databases

Datetime

Developer Tools

  • Try OCaml – Try OCaml in your web browser.

  • learn-ocaml. Web app (written in OCaml) underlying the learn-ocaml-corpus. Can be customized to serve lectures (with Markdown slides), playgrounds (with a toplevel prelude), and interactive exercises (with OCaml tests). MIT License.

  • learn-ocaml.el. Minor mode for Emacs that can display exercise topics and grade exercise solutions, after logging to a Learn-OCaml instance. MIT License.

  • BetterOCaml – An efficient, intuitive, and cross-platform web IDE with your OCaml code interpreted and running in your browser!

  • codingground – Compile and execute OCaml code online.

  • OCaml: Learn & Code iOS app - Learn and execute OCaml code from your iPhone/iPad/Mac.

  • Jupyter – An OCaml kernel for the Jupyter notebook.

  • utop – Universal toplevel for OCaml with support for multiline edition, history, real-time and context-sensitive completion, colors, and more.

  • ocamlformat - A command-line tool to format OCaml code.

  • ocamlbrowser – A source and compiled interface browser, written using LablTk. Included in the standard distribution for ocaml <= 4.01 and with labltk for ocaml >= 4.02.

  • ghim – A command-line tool to manage Github Issues.

  • OCaml Yeoman Generator – Yeoman generator to scaffold OCaml modules.

  • puml2xml – A PlantUML (.puml) to XML (.xmi) converter.

  • Foreign Function Interface:

  • Editor Integration:

  • Code coverage:

Exercises and Short Examples

Formal Software Verification

  • 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

Internationalization

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, and colors, as well as a set of widgets to write curses-like applications.
  • Notty - Notty is a declarative terminal library for OCaml, structured around the 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
  • 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.
  • Tezos - a self-upgradable Proof of Stake blockchain
  • 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 the Bolt OCaml logging tool.
  • Logs - Logs provides a logging infrastructure for OCaml.

Machine Learning

  • Libraries
  • Articles
    • [Deep Learning with OCaml (PyTorch bindings)](https://blog.janestreet.com/deep-learning-experiments-in-ocaml/).
    • [Transfer Learning with OCaml (PyTorch bindings)](https://blog.janestreet.com/of-pythons-and-camels/).
    • [Reinforcement Learning with OCaml (PyTorch bindings)](https://blog.janestreet.com/playing-atari-games-with-ocaml-and-deep-rl/).

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.

Metaprogramming

Metrics

Mobile Applications

  • Articles:
    • OCaml on iOS 7 Released
    • [OCaml + Cordova = more secured, typed and hybrid mobile applications](https://dannywillems.github.io/2016/07/14/ocaml-cordova-secured-typed-hybrid-mobile-applications.html)
  • 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 (deprecated since 2021).
    • Diskuv OCaml - Diskuv OCaml distribution 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:

Printers helpers

  • Reason's native Console.log
  • Dum
  • Inspect
  • ppx_deriving ’s [@@deriving show].
  • refl , a ppx_deriving-like.
  • lrt , another ppx_deriving-like.
  • tpf , again a ppx_deriving-like.
  • typerep , probably a ppx_deriving-like with ppx_typerep_conv.
  • repr, which appears to have the user build the type representation manually from combinators in addition to also having the user pass it where needed.
  • data-encoding, also fully manual.
  • cmon , fully manual.
  • dyn in Dune. It appears to also be fully manual.
  • Genprint
  • OCaml@p

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

truncated — full list on GitHub

[[curator]]
I'm the Curator. I can help you navigate, organize, and curate this wiki. What would you like to do?